From 5de0768ec8bece340d9b641bcbe435b9597a2f99 Mon Sep 17 00:00:00 2001 From: STAM Date: Tue, 30 Jul 2024 23:31:58 +0300 Subject: [PATCH 1/2] CVE FIXES --- Makefile | 3 + .../atlassian/bitbucket/8/8.19.6/Dockerfile | 46 ++++ .../bitbucket/8/8.19.6/Dockerfile.jdk11 | 47 ++++ .../bitbucket/8/8.19.6/Dockerfile.jdk17 | 46 ++++ .../atlassian/bitbucket/8/8.19.6/Makefile | 50 ++++ .../atlassian/bitbucket/8/8.19.6/README.md | 216 ++++++++++++++++++ .../bitbucket/8/8.19.6/docker-compose.yml | 16 ++ .../bitbucket/8/8.19.6/entrypoint.sh | 57 +++++ .../bitbucket/8/8.19.6/kaniko-build.py | 196 ++++++++++++++++ .../bitbucket/8/8.19.6/requirements.txt | 2 + .../atlassian/bitbucket/9/9.0.0/Dockerfile | 46 ++++ .../bitbucket/9/9.0.0/Dockerfile.jdk11 | 46 ++++ .../bitbucket/9/9.0.0/Dockerfile.jdk17 | 46 ++++ .../atlassian/bitbucket/9/9.0.0/Makefile | 50 ++++ .../atlassian/bitbucket/9/9.0.0/README.md | 216 ++++++++++++++++++ .../bitbucket/9/9.0.0/docker-compose.yml | 16 ++ .../atlassian/bitbucket/9/9.0.0/entrypoint.sh | 57 +++++ .../bitbucket/9/9.0.0/kaniko-build.py | 196 ++++++++++++++++ .../bitbucket/9/9.0.0/requirements.txt | 2 + .../atlassian/confluence/8/8.8.1/Dockerfile | 48 ++++ .../confluence/8/8.8.1/Dockerfile.jdk11 | 49 ++++ .../confluence/8/8.8.1/Dockerfile.jdk17 | 49 ++++ .../atlassian/confluence/8/8.8.1/Makefile | 50 ++++ .../confluence/8/8.8.1/docker-compose.yml | 17 ++ .../confluence/8/8.8.1/entrypoint.sh | 39 ++++ .../confluence/8/8.8.1/kaniko-build.py | 196 ++++++++++++++++ .../confluence/8/8.8.1/requirements.txt | 2 + .../atlassian/confluence/8/8.9.5/Dockerfile | 48 ++++ .../confluence/8/8.9.5/Dockerfile.jdk11 | 49 ++++ .../confluence/8/8.9.5/Dockerfile.jdk17 | 49 ++++ .../atlassian/confluence/8/8.9.5/Makefile | 50 ++++ .../confluence/8/8.9.5/docker-compose.yml | 16 ++ .../confluence/8/8.9.5/entrypoint.sh | 39 ++++ .../confluence/8/8.9.5/kaniko-build.py | 196 ++++++++++++++++ .../confluence/8/8.9.5/requirements.txt | 2 + .../atlassian/confluence/9/9.0.0/Dockerfile | 48 ++++ .../confluence/9/9.0.0/Dockerfile.jdk11 | 49 ++++ .../confluence/9/9.0.0/Dockerfile.jdk17 | 49 ++++ .../atlassian/confluence/9/9.0.0/Makefile | 50 ++++ .../confluence/9/9.0.0/docker-compose.yml | 16 ++ .../confluence/9/9.0.0/entrypoint.sh | 39 ++++ .../confluence/9/9.0.0/kaniko-build.py | 196 ++++++++++++++++ .../confluence/9/9.0.0/requirements.txt | 2 + .../atlassian/confluence/9/9.0.1/Dockerfile | 48 ++++ .../confluence/9/9.0.1/Dockerfile.jdk11 | 49 ++++ .../confluence/9/9.0.1/Dockerfile.jdk17 | 49 ++++ .../atlassian/confluence/9/9.0.1/Makefile | 50 ++++ .../confluence/9/9.0.1/docker-compose.yml | 16 ++ .../confluence/9/9.0.1/entrypoint.sh | 39 ++++ .../confluence/9/9.0.1/kaniko-build.py | 196 ++++++++++++++++ .../confluence/9/9.0.1/requirements.txt | 2 + .../atlassian/jira/9/9.12.12/Dockerfile | 53 +++++ .../atlassian/jira/9/9.12.12/Dockerfile.jdk11 | 52 +++++ .../atlassian/jira/9/9.12.12/Dockerfile.jdk17 | 52 +++++ .../atlassian/jira/9/9.12.12/Makefile | 50 ++++ .../jira/9/9.12.12/docker-compose.yml | 16 ++ .../atlassian/jira/9/9.12.12/entrypoint.sh | 89 ++++++++ .../atlassian/jira/9/9.12.12/kaniko-build.py | 196 ++++++++++++++++ .../atlassian/jira/9/9.12.12/requirements.txt | 2 + linux/ecosystem/atlassian/jira/9/9.12.2/.env | 2 - .../atlassian/jira/9/9.12.2/Dockerfile | 7 +- .../atlassian/jira/9/9.12.2/Dockerfile.jdk11 | 7 +- .../atlassian/jira/9/9.12.2/Dockerfile.jdk17 | 7 +- .../jira/9/9.12.2/docker-compose.yml | 15 +- .../atlassian/jira/9/9.14.1/Dockerfile | 53 +++++ .../atlassian/jira/9/9.14.1/Dockerfile.jdk11 | 52 +++++ .../atlassian/jira/9/9.14.1/Dockerfile.jdk17 | 52 +++++ .../atlassian/jira/9/9.14.1/Makefile | 50 ++++ .../jira/9/9.14.1/docker-compose.yml | 16 ++ .../atlassian/jira/9/9.14.1/entrypoint.sh | 89 ++++++++ .../atlassian/jira/9/9.14.1/kaniko-build.py | 196 ++++++++++++++++ .../atlassian/jira/9/9.14.1/requirements.txt | 2 + .../atlassian/jira/9/9.16.1/Dockerfile | 53 +++++ .../atlassian/jira/9/9.16.1/Dockerfile.jdk11 | 52 +++++ .../atlassian/jira/9/9.16.1/Dockerfile.jdk17 | 52 +++++ .../atlassian/jira/9/9.16.1/Makefile | 50 ++++ .../jira/9/9.16.1/docker-compose.yml | 16 ++ .../atlassian/jira/9/9.16.1/entrypoint.sh | 89 ++++++++ .../atlassian/jira/9/9.16.1/kaniko-build.py | 196 ++++++++++++++++ .../atlassian/jira/9/9.16.1/requirements.txt | 2 + .../atlassian/jira/9/9.17.1/Dockerfile | 53 +++++ .../atlassian/jira/9/9.17.1/Dockerfile.jdk11 | 52 +++++ .../atlassian/jira/9/9.17.1/Dockerfile.jdk17 | 52 +++++ .../atlassian/jira/9/9.17.1/Makefile | 50 ++++ .../jira/9/9.17.1/docker-compose.yml | 17 ++ .../atlassian/jira/9/9.17.1/entrypoint.sh | 89 ++++++++ .../atlassian/jira/9/9.17.1/kaniko-build.py | 196 ++++++++++++++++ .../atlassian/jira/9/9.17.1/requirements.txt | 2 + .../debian/12-bookworm/develop/Dockerfile | 23 +- .../debian/12-bookworm/jdk11/Dockerfile | 2 + .../debian/12-bookworm/jdk16/Dockerfile | 2 + .../debian/12-bookworm/jdk17/Dockerfile | 2 + .../debian/12-bookworm/jdk18/Dockerfile | 2 + .../debian/12-bookworm/jdk19/Dockerfile | 2 + .../debian/12-bookworm/jdk20/Dockerfile | 2 + .../debian/12-bookworm/jdk21/Dockerfile | 2 + .../debian/12-bookworm/jdk22/Dockerfile | 2 + .../debian/12-bookworm/jdk6/Dockerfile | 2 + .../debian/12-bookworm/jdk7/Dockerfile | 2 + .../debian/12-bookworm/jdk8/Dockerfile | 2 + linux/ecosystem/nginx/1.27.0/main/Dockerfile | 8 +- 101 files changed, 5242 insertions(+), 41 deletions(-) create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.19.6/Dockerfile create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.19.6/Dockerfile.jdk11 create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.19.6/Dockerfile.jdk17 create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.19.6/Makefile create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.19.6/README.md create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.19.6/docker-compose.yml create mode 100755 linux/ecosystem/atlassian/bitbucket/8/8.19.6/entrypoint.sh create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.19.6/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.19.6/requirements.txt create mode 100644 linux/ecosystem/atlassian/bitbucket/9/9.0.0/Dockerfile create mode 100644 linux/ecosystem/atlassian/bitbucket/9/9.0.0/Dockerfile.jdk11 create mode 100644 linux/ecosystem/atlassian/bitbucket/9/9.0.0/Dockerfile.jdk17 create mode 100644 linux/ecosystem/atlassian/bitbucket/9/9.0.0/Makefile create mode 100644 linux/ecosystem/atlassian/bitbucket/9/9.0.0/README.md create mode 100644 linux/ecosystem/atlassian/bitbucket/9/9.0.0/docker-compose.yml create mode 100755 linux/ecosystem/atlassian/bitbucket/9/9.0.0/entrypoint.sh create mode 100644 linux/ecosystem/atlassian/bitbucket/9/9.0.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/bitbucket/9/9.0.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/8/8.8.1/Dockerfile create mode 100644 linux/ecosystem/atlassian/confluence/8/8.8.1/Dockerfile.jdk11 create mode 100644 linux/ecosystem/atlassian/confluence/8/8.8.1/Dockerfile.jdk17 create mode 100644 linux/ecosystem/atlassian/confluence/8/8.8.1/Makefile create mode 100644 linux/ecosystem/atlassian/confluence/8/8.8.1/docker-compose.yml create mode 100755 linux/ecosystem/atlassian/confluence/8/8.8.1/entrypoint.sh create mode 100644 linux/ecosystem/atlassian/confluence/8/8.8.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/8/8.8.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/8/8.9.5/Dockerfile create mode 100644 linux/ecosystem/atlassian/confluence/8/8.9.5/Dockerfile.jdk11 create mode 100644 linux/ecosystem/atlassian/confluence/8/8.9.5/Dockerfile.jdk17 create mode 100644 linux/ecosystem/atlassian/confluence/8/8.9.5/Makefile create mode 100644 linux/ecosystem/atlassian/confluence/8/8.9.5/docker-compose.yml create mode 100755 linux/ecosystem/atlassian/confluence/8/8.9.5/entrypoint.sh create mode 100644 linux/ecosystem/atlassian/confluence/8/8.9.5/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/8/8.9.5/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.0/Dockerfile create mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.0/Dockerfile.jdk11 create mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.0/Dockerfile.jdk17 create mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.0/Makefile create mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.0/docker-compose.yml create mode 100755 linux/ecosystem/atlassian/confluence/9/9.0.0/entrypoint.sh create mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.0/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.0/requirements.txt create mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.1/Dockerfile create mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.1/Dockerfile.jdk11 create mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.1/Dockerfile.jdk17 create mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.1/Makefile create mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.1/docker-compose.yml create mode 100755 linux/ecosystem/atlassian/confluence/9/9.0.1/entrypoint.sh create mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.12.12/Dockerfile create mode 100644 linux/ecosystem/atlassian/jira/9/9.12.12/Dockerfile.jdk11 create mode 100644 linux/ecosystem/atlassian/jira/9/9.12.12/Dockerfile.jdk17 create mode 100644 linux/ecosystem/atlassian/jira/9/9.12.12/Makefile create mode 100644 linux/ecosystem/atlassian/jira/9/9.12.12/docker-compose.yml create mode 100755 linux/ecosystem/atlassian/jira/9/9.12.12/entrypoint.sh create mode 100644 linux/ecosystem/atlassian/jira/9/9.12.12/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.12.12/requirements.txt delete mode 100644 linux/ecosystem/atlassian/jira/9/9.12.2/.env create mode 100644 linux/ecosystem/atlassian/jira/9/9.14.1/Dockerfile create mode 100644 linux/ecosystem/atlassian/jira/9/9.14.1/Dockerfile.jdk11 create mode 100644 linux/ecosystem/atlassian/jira/9/9.14.1/Dockerfile.jdk17 create mode 100644 linux/ecosystem/atlassian/jira/9/9.14.1/Makefile create mode 100644 linux/ecosystem/atlassian/jira/9/9.14.1/docker-compose.yml create mode 100755 linux/ecosystem/atlassian/jira/9/9.14.1/entrypoint.sh create mode 100644 linux/ecosystem/atlassian/jira/9/9.14.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.14.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.16.1/Dockerfile create mode 100644 linux/ecosystem/atlassian/jira/9/9.16.1/Dockerfile.jdk11 create mode 100644 linux/ecosystem/atlassian/jira/9/9.16.1/Dockerfile.jdk17 create mode 100644 linux/ecosystem/atlassian/jira/9/9.16.1/Makefile create mode 100644 linux/ecosystem/atlassian/jira/9/9.16.1/docker-compose.yml create mode 100755 linux/ecosystem/atlassian/jira/9/9.16.1/entrypoint.sh create mode 100644 linux/ecosystem/atlassian/jira/9/9.16.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.16.1/requirements.txt create mode 100644 linux/ecosystem/atlassian/jira/9/9.17.1/Dockerfile create mode 100644 linux/ecosystem/atlassian/jira/9/9.17.1/Dockerfile.jdk11 create mode 100644 linux/ecosystem/atlassian/jira/9/9.17.1/Dockerfile.jdk17 create mode 100644 linux/ecosystem/atlassian/jira/9/9.17.1/Makefile create mode 100644 linux/ecosystem/atlassian/jira/9/9.17.1/docker-compose.yml create mode 100755 linux/ecosystem/atlassian/jira/9/9.17.1/entrypoint.sh create mode 100644 linux/ecosystem/atlassian/jira/9/9.17.1/kaniko-build.py create mode 100644 linux/ecosystem/atlassian/jira/9/9.17.1/requirements.txt diff --git a/Makefile b/Makefile index fd22bd002..0c3590f8f 100644 --- a/Makefile +++ b/Makefile @@ -418,6 +418,9 @@ ecosystem-debian-bookworm-images: cd `pwd`/linux/ecosystem/epicmorg/debian/12-bookworm/slim && pwd && make build && make deploy cd `pwd`/linux/ecosystem/epicmorg/debian/12-bookworm/main && pwd && make build && make deploy cd `pwd`/linux/ecosystem/epicmorg/debian/12-bookworm/develop && pwd && make build && make deploy + make ecosystem-debian-bookworm-jdk-images + +ecosystem-debian-bookworm-jdk-images: cd `pwd`/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6 && pwd && make build && make deploy cd `pwd`/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7 && pwd && make build && make deploy cd `pwd`/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8 && pwd && make build && make deploy diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Dockerfile b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Dockerfile new file mode 100644 index 000000000..69335bafa --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Dockerfile @@ -0,0 +1,46 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG BITBUCKET_VERSION=8.19.6 +ARG DOWNLOAD_URL=https://product-downloads.atlassian.com/software/stash/downloads/atlassian-bitbucket-${BITBUCKET_VERSION}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/BitbucketServer/Bitbucket+Server+home+directory +ENV BITBUCKET_HOME /var/atlassian/application-data/bitbucket +ENV BITBUCKET_INSTALL_DIR /opt/atlassian/bitbucket + +VOLUME ["${BITBUCKET_HOME}"] +WORKDIR $BITBUCKET_HOME + +# Expose HTTP and SSH ports +EXPOSE 7990 +EXPOSE 7999 + +################################################################## +# Installing +################################################################## +RUN apt-get update && \ + apt-get install -y --allow-downgrades git/bookworm + +RUN mkdir -p ${BITBUCKET_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "${BITBUCKET_INSTALL_DIR}" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${BITBUCKET_INSTALL_DIR}/ \ + && sed -i -e 's/^# umask/umask/' ${BITBUCKET_INSTALL_DIR}/bin/_start-webapp.sh && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] +COPY entrypoint.sh /entrypoint.sh diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Dockerfile.jdk11 b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Dockerfile.jdk11 new file mode 100644 index 000000000..f322f3ce4 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Dockerfile.jdk11 @@ -0,0 +1,47 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG BITBUCKET_VERSION=8.19.6 +ARG DOWNLOAD_URL=https://product-downloads.atlassian.com/software/stash/downloads/atlassian-bitbucket-${BITBUCKET_VERSION}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/BitbucketServer/Bitbucket+Server+home+directory +ENV BITBUCKET_HOME /var/atlassian/application-data/bitbucket +ENV BITBUCKET_INSTALL_DIR /opt/atlassian/bitbucket + +VOLUME ["${BITBUCKET_HOME}"] +WORKDIR $BITBUCKET_HOME + +# Expose HTTP and SSH ports +EXPOSE 7990 +EXPOSE 7999 + +################################################################## +# Installing +################################################################## +RUN apt-get update && \ + apt-get install -y --allow-downgrades git/bookworm + +RUN mkdir -p ${BITBUCKET_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "${BITBUCKET_INSTALL_DIR}" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${BITBUCKET_INSTALL_DIR}/ \ + && sed -i -e 's/^# umask/umask/' ${BITBUCKET_INSTALL_DIR}/bin/_start-webapp.sh && \ + + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] +COPY entrypoint.sh /entrypoint.sh diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Dockerfile.jdk17 b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Dockerfile.jdk17 new file mode 100644 index 000000000..76c9c0d45 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Dockerfile.jdk17 @@ -0,0 +1,46 @@ +FROM epicmorg/debian:bookworm-jdk17 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG BITBUCKET_VERSION=8.19.6 +ARG DOWNLOAD_URL=https://product-downloads.atlassian.com/software/stash/downloads/atlassian-bitbucket-${BITBUCKET_VERSION}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/BitbucketServer/Bitbucket+Server+home+directory +ENV BITBUCKET_HOME /var/atlassian/application-data/bitbucket +ENV BITBUCKET_INSTALL_DIR /opt/atlassian/bitbucket + +VOLUME ["${BITBUCKET_HOME}"] +WORKDIR $BITBUCKET_HOME + +# Expose HTTP and SSH ports +EXPOSE 7990 +EXPOSE 7999 + +################################################################## +# Installing +################################################################## +RUN apt-get update && \ + apt-get install -y --allow-downgrades git/bookworm + +RUN mkdir -p ${BITBUCKET_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "${BITBUCKET_INSTALL_DIR}" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${BITBUCKET_INSTALL_DIR}/ \ + && sed -i -e 's/^# umask/umask/' ${BITBUCKET_INSTALL_DIR}/bin/_start-webapp.sh && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] +COPY entrypoint.sh /entrypoint.sh diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Makefile new file mode 100644 index 000000000..3383c9699 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Makefile @@ -0,0 +1,50 @@ +PIP_BREAK_SYSTEM_PACKAGES=1 + +all: app + +app: + make build + make deploy + make clean + +build: + make pip + python3 kaniko-build.py --version + +dry: + make dry-run + +test: + make dry-run + +dry-run: + python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + +pip: + rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.7/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.8/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.12/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.13/EXTERNALLY-MANAGED + pip3 install -r requirements.txt + pip install -r requirements.txt + +build-compose: + docker-compose build --compress --parallel --progress plain + +deploy: + make pip + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + +deploy-compose: + docker-compose push + +clean: + docker container prune -f + docker image prune -f + docker network prune -f + docker volume prune -f + docker system prune -af diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.19.6/README.md b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/README.md new file mode 100644 index 000000000..b60c42068 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/README.md @@ -0,0 +1,216 @@ +![Atlassian Bitbucket Server](https://www.atlassian.com/dam/wac/legacy/bitbucket_logo_landing.png) + +Bitbucket Server is an on-premises source code management solution for Git that's secure, fast, and enterprise grade. Create and manage repositories, set up fine-grained permissions, and collaborate on code - all with the flexibility of your servers. + +Learn more about Bitbucket Server: + +# Overview + +This Docker container makes it easy to get an instance of Bitbucket up and running. + +** We strongly recommend you run this image using a specific version tag instead of latest. This is because the image referenced by the latest tag changes often and we cannot guarantee that it will be backwards compatible. ** + +# Quick Start + +For the `BITBUCKET_HOME` directory that is used to store the repository data +(amongst other things) we recommend mounting a host directory as a [data volume](https://docs.docker.com/engine/tutorials/dockervolumes/#/data-volumes), or via a named volume if using a docker version >= 1.9. + +Volume permission is managed by entry scripts. To get started you can use a data volume, or named volumes. In this example we'll use named volumes. + + $> docker volume create --name bitbucketVolume + $> docker run -v bitbucketVolume:/var/atlassian/application-data/bitbucket --name="bitbucket" -d -p 7990:7990 -p 7999:7999 atlassian/bitbucket-server + +Note that this command can substitute folder paths with named volumes. + +Start Atlassian Bitbucket Server: + + $> docker run -v /data/bitbucket:/var/atlassian/application-data/bitbucket --name="bitbucket" -d -p 7990:7990 -p 7999:7999 atlassian/bitbucket-server + +**Success**. Bitbucket is now available on [http://localhost:7990](http://localhost:7990)* + +Please ensure your container has the necessary resources allocated to it. +We recommend 2GiB of memory allocated to accommodate both the application server +and the git processes. +See [Supported Platforms](https://confluence.atlassian.com/display/BitbucketServer/Supported+platforms) for further information. + + +_* Note: If you are using `docker-machine` on Mac OS X, please use `open http://$(docker-machine ip default):7990` instead._ + +## Reverse Proxy Settings + +If Bitbucket is run behind a reverse proxy server as [described here](https://confluence.atlassian.com/bitbucketserver/proxying-and-securing-bitbucket-server-776640099.html), +then you need to specify extra options to make bitbucket aware of the setup. They can be controlled via the below +environment variables. + +### Bitbucket Server 5.0 + + +Due to the migration to Spring Boot in 5.0, there are changes to how you set up Bitbucket to run behind a reverse proxy. + +In this example, we'll use an environment file. You can also do this via [specifying each environment variable](https://docs.docker.com/engine/reference/run/#env-environment-variables) via the `-e` argument in `docker run`. + +#### secure-bitbucket.env +``` +SERVER_SECURE=true +SERVER_SCHEME=https +SERVER_PROXY_PORT=443 +SERVER_PROXY_NAME= +``` + +Then you run Bitbucket as usual + +`docker run -v bitbucketVolume:/var/atlassian/application-data/bitbucket --name="bitbucket" -d -p 7990:7990 -p 7999:7999 --env-file=/path/to/env/file/secure-bitbucket.env atlassian/bitbucket-server:5.0` + +### Bitbucket Server < 5.0 + +To set the reverse proxy arguments, you specify the following as environment variables in the `docker run` command + +* `CATALINA_CONNECTOR_PROXYNAME` (default: NONE) + + The reverse proxy's fully qualified hostname. + +* `CATALINA_CONNECTOR_PROXYPORT` (default: NONE) + + The reverse proxy's port number via which bitbucket is accessed. + +* `CATALINA_CONNECTOR_SCHEME` (default: http) + + The protocol via which bitbucket is accessed. + +* `CATALINA_CONNECTOR_SECURE` (default: false) + + Set 'true' if CATALINA\_CONNECTOR\_SCHEME is 'https'. + +## JVM Configuration (Bitbucket Server 5.0 + only) + +If you need to override Bitbucket Server's default memory configuration or pass additional JVM arguments, use the environment variables below + +* `JVM_MINIMUM_MEMORY` (default: 512m) + + The minimum heap size of the JVM + +* `JVM_MAXIMUM_MEMORY` (default: 1024m) + + The maximum heap size of the JVM + +* `JVM_SUPPORT_RECOMMENDED_ARGS` (default: NONE) + + Additional JVM arguments for Bitbucket Server, such as a custom Java Trust Store + +## Application Mode Settings (Bitbucket Server 5.0 + only) + +This docker image can be run as a [Smart Mirror](https://confluence.atlassian.com/bitbucketserver/smart-mirroring-776640046.html) or as part of a [Data Center](https://confluence.atlassian.com/enterprise/bitbucket-data-center-668468332.html) cluster. +You can specify the following properties to start Bitbucket as a mirror or as a Data Center node: + +* `ELASTICSEARCH_ENABLED` (default: true) + + Set 'false' to prevent Elasticsearch from starting in the container. This should be used if Elasticsearch is running remotely, e.g. for if Bitbucket is running in a Data Center cluster + +* `APPLICATION_MODE` (default: default) + + The mode Bitbucket will run in. This can be set to 'mirror' to start Bitbucket as a Smart Mirror. This will also disable Elasticsearch even if `ELASTICSEARCH_ENABLED` has not been set to 'false'. + +* `HAZELCAST_NETWORK_MULTICAST` (default: false) + + Data Center: Set 'true' to enable Bitbucket to find new Data Center cluster members via multicast. `HAZELCAST_NETWORK_TCPIP` should not be specified when using this setting. + +* `HAZELCAST_NETWORK_TCPIP` (default: false) + + Data Center: Set 'true' to enable Bitbucket to find new Data Center cluster members via TCPIP. This setting requires `HAZELCAST_NETWORK_TCPIP_MEMBERS` to be specified. `HAZELCAST_NETWORK_MULTICAST` should not be specified when using this setting. + +* `HAZELCAST_NETWORK_TCPIP_MEMBERS` + + Data Center: List of members that Hazelcast nodes should connect to when HAZELCAST_NETWORK_TCPIP is 'true' + +* `HAZELCAST_GROUP_NAME` + + Data Center: Specifies the cluster group the instance should join. + +* `HAZELCAST_GROUP_PASSWORD` + + Data Center: The password required to join the specified cluster group. + +To run Bitbucket as part of a Data Center cluster, create a Docker network and assign the Bitbucket container a static IP. + +Note: Docker networks may support multicast, however the below example shows configuration using TCPIP. + + $> docker network create --driver bridge --subnet=172.18.0.0/16 myBitbucketNetwork + $> docker run --network=myBitbucketNetwork --ip=172.18.1.1 -e ELASTICSEARCH_ENABLED=false \ + -e HAZELCAST_NETWORK_TCPIP=true -e HAZELCAST_NETWORK_TCPIP_MEMBERS=172.18.1.1:5701,172.18.1.2:5701,172.18.1.3:5701 \ + -e HAZELCAST_GROUP_NAME=bitbucket -e HAZELCAST_GROUP_PASSWORD=mysecretpassword \ + -v /data/bitbucket-shared:/var/atlassian/application-data/bitbucket/shared --name="bitbucket" -d -p 7990:7990 -p 7999:7999 atlassian/bitbucket-server + +## JMX Monitoring (Bitbucket Server 5.0 + only) + +Bitbucket Server supports detailed JMX monitoring. To enable and configure JMX, use the environment variables below. For further information on JMX configuration, see [Enabling JMX counters for performance monitoring](https://confluence.atlassian.com/bitbucketserver/enabling-jmx-counters-for-performance-monitoring-776640189.html) + +* `JMX_ENABLED` (default: false) + + Enable Bitbucket to publish JMX data + +* `JMX_REMOTE_AUTH` (default: NONE) + + Set the authentication to use for remote JMX access. This value is required: anything other than "password" or "ssl" will cause remote JMX access to be disabled + +* `JMX_REMOTE_PORT` (default: 3333) + + The port used to negotiate a JMX connection. Note: this port is only used during the initial authorization, after which a different RMI port used for data transfer + +* `JMX_REMOTE_RMI_PORT` (default: ) + + The port used for all subsequent JMX-RMI data transfer. If desired, the RMI data port can be set to the same value as `JMX_REMOTE_PORT` to allow a single port to be used for both JMX authorization and data transfer + +* `RMI_SERVER_HOSTNAME` (default: NONE) + + The hostname or IP address that clients will use to connect to the application for JMX monitoring. This must be resolvable by both clients and from the JVM host machine. + +* `JMX_PASSWORD_FILE` (default: NONE) + + The full path to the JMX username/password file used to authenticate remote JMX clients. This is required when `JMX_REMOTE_AUTH` is set to "password" + + $> docker run -e JMX_ENABLED=true -e JMX_REMOTE_AUTH=password -e JMX_REMOTE_RMI_PORT=3333 -e RMI_SERVER_HOSTNAME=bitbucket \ + -e JMX_PASSWORD_FILE=/data/bitbucket:/var/atlassian/application-data/bitbucket/jmx.access \ + -v /data/bitbucket:/var/atlassian/application-data/bitbucket --name="bitbucket" -d -p 7990:7990 -p 7999:7999 -p 3333:3333 atlassian/bitbucket-server + +# Upgrade + +To upgrade to a more recent version of Bitbucket Server you can simply stop the `bitbucket` +container and start a new one based on a more recent image: + + $> docker stop bitbucket + $> docker rm bitbucket + $> docker pull atlassian/bitbucket-server: + $> docker run ... (See above) + +As your data is stored in the data volume directory on the host it will still +be available after the upgrade. + +_Note: Please make sure that you **don't** accidentally remove the `bitbucket` +container and its volumes using the `-v` option._ + +# Backup + +For evaluations you can use the built-in database that will store its files in the Bitbucket Server home directory. In that case it is sufficient to create a backup archive of the directory on the host that is used as a volume (`/data/bitbucket` in the example above). + +The [Bitbucket Server Backup Client](https://confluence.atlassian.com/display/BitbucketServer/Data+recovery+and+backups) is currently not supported in the Docker setup. You can however use the [Bitbucket Server DIY Backup](https://confluence.atlassian.com/display/BitbucketServer/Using+Bitbucket+Server+DIY+Backup) approach in case you decided to use an external database. + +Read more about data recovery and backups: [https://confluence.atlassian.com/display/BitbucketServer/Data+recovery+and+backups](https://confluence.atlassian.com/display/BitbucketServer/Data+recovery+and+backups) + +# Versioning + +The `latest` tag matches the most recent version of this repository. Thus using `atlassian/bitbucket:latest` or `atlassian/bitbucket` will ensure you are running the most up to date version of this image. + +However, we ** strongly recommend ** that for non-eval workloads you select a specific version in order to prevent breaking changes from impacting your setup. +You can use a specific minor version of Bitbucket Server by using a version number +tag: `atlassian/bitbucket-server:4.14`. This will install the latest `4.14.x` version that +is available. + + +# Issue tracker + +Please raise an [issue](https://bitbucket.org/atlassian/docker-atlassian-bitbucket-server/issues) if you encounter any problems with this Dockerfile. + +# Support + +For product support, go to [support.atlassian.com](https://support.atlassian.com/) +Octotree is enabled on this page. Click this button or press cmd shift s (or ctrl shift s) to show it. +Support us • Feedback? diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.19.6/docker-compose.yml b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/docker-compose.yml new file mode 100644 index 000000000..ce8e2b411 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/docker-compose.yml @@ -0,0 +1,16 @@ +#version: '3' +services: + app: + image: "epicmorg/bitbucket:8.19.6" + build: + context: . + app-jdk11: + image: "epicmorg/bitbucket:8.19.6-jdk11" + build: + context: . + dockerfile: ./Dockerfile.jdk11 + app-jdk17: + image: "epicmorg/bitbucket:8.19.6-jdk17" + build: + context: . + dockerfile: ./Dockerfile.jdk17 diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.19.6/entrypoint.sh b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/entrypoint.sh new file mode 100755 index 000000000..842224a8c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/entrypoint.sh @@ -0,0 +1,57 @@ +#!/bin/bash +set -euo pipefail + +# Set recommended umask of "u=,g=w,o=rwx" (0027) +umask 0027 + +export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") +export JRE_HOME="$JAVA_HOME/jre" +export JAVA_BINARY="$JRE_HOME/bin/java" +export JAVA_VERSION=$("$JAVA_BINARY" -version 2>&1 | awk -F '"' '/version/ {print $2}') + +#export PATH=$JAVA_HOME/bin:$PATH + + +# Setup Catalina Opts +: ${CATALINA_CONNECTOR_PROXYNAME:=} +: ${CATALINA_CONNECTOR_PROXYPORT:=} +: ${CATALINA_CONNECTOR_SCHEME:=http} +: ${CATALINA_CONNECTOR_SECURE:=false} + +: ${CATALINA_OPTS:=} + +: ${JAVA_OPTS:=} + +: ${ELASTICSEARCH_ENABLED:=true} +: ${APPLICATION_MODE:=} + +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyName=${CATALINA_CONNECTOR_PROXYNAME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyPort=${CATALINA_CONNECTOR_PROXYPORT}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorScheme=${CATALINA_CONNECTOR_SCHEME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorSecure=${CATALINA_CONNECTOR_SECURE}" + +JAVA_OPTS="${JAVA_OPTS} ${CATALINA_OPTS}" + +ARGS="$@" + +# Start Bitbucket without Elasticsearch +if [ "${ELASTICSEARCH_ENABLED}" == "false" ] || [ "${APPLICATION_MODE}" == "mirror" ]; then + ARGS="--no-search ${ARGS}" +fi + +# Start Bitbucket as the correct user. +if [ "${UID}" -eq 0 ]; then + echo "User is currently root. Will change directory ownership to ${RUN_USER}:${RUN_GROUP}, then downgrade permission to ${RUN_USER}" + PERMISSIONS_SIGNATURE=$(stat -c "%u:%U:%a" "${BITBUCKET_HOME}") + EXPECTED_PERMISSIONS=$(id -u ${RUN_USER}):${RUN_USER}:700 + if [ "${PERMISSIONS_SIGNATURE}" != "${EXPECTED_PERMISSIONS}" ]; then + echo "Updating permissions for BITBUCKET_HOME" + mkdir -p "${BITBUCKET_HOME}/lib" && + chmod -R 700 "${BITBUCKET_HOME}" && + chown -R "${RUN_USER}:${RUN_GROUP}" "${BITBUCKET_HOME}" + fi + # Now drop privileges + exec su -s /bin/bash "${RUN_USER}" -c "${BITBUCKET_INSTALL_DIR}/bin/start-bitbucket.sh ${ARGS}" +else + exec "${BITBUCKET_INSTALL_DIR}/bin/start-bitbucket.sh" ${ARGS} +fi diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.19.6/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/kaniko-build.py new file mode 100644 index 000000000..e693b5c17 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/kaniko-build.py @@ -0,0 +1,196 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections import defaultdict +from concurrent.futures import ThreadPoolExecutor, as_completed +from dotenv import load_dotenv +import logging +import sys + +# Script version +SCRIPT_VERSION = "1.0.1.0" + +# ASCII art for EpicMorg +ASCII_ART = r""" ++=================================================+ +| ____| _) \ | | +| __| __ \ | __| |\/ | _ \ __| _` | | +| | | | | ( | | ( | | ( | | +|_____| .__/ _| \___| _| _| \___/ _| \__, | | +| | / _| _) | |___/ | +| ' / _` | __ \ | | / _ \ | +| . \ ( | | | | < ( | | +|_|\_\ \__,_| _| _| _| _|\_\ \___/ | +|\ \ / | +| \ \ \ / __| _` | __ \ __ \ _ \ __|| +| \ \ \ / | ( | | | | | __/ | | +| \_/\_/ _| \__,_| .__/ .__/ \___| _| | +| _| _| | ++=================================================+ +""" + +# Load environment variables from .env file +load_dotenv() + +def setup_logging(): + logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + +def parse_args(): + parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) + parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') + parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') + parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') + parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') + parser.add_argument('--version', '-v', action='store_true', help='Show script version') + parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') + return parser.parse_args() + +def load_compose_file(file_path): + with open(file_path, 'r') as file: + return yaml.safe_load(file) + +def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): + kaniko_command = [ + 'docker', 'run', + '--rm', + '-t', + '-v', f'{os.path.abspath(build_context)}:/workspace', + ] + + # Add Docker config mounts for both read-only access + kaniko_command.extend([ + '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon + '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode + ]) + + kaniko_command.extend([ + kaniko_image, + '--context', '/workspace', + '--dockerfile', f'/workspace/{dockerfile}', + '--compressed-caching', + '--single-snapshot', + '--cleanup' + ]) + + if deploy: + kaniko_command.extend([ + '--destination', image_name + ]) + elif dry: + kaniko_command.extend([ + '--no-push' + ]) + else: + kaniko_command.extend([ + '--no-push' + ]) + + # Add build arguments if they exist + for arg_name, arg_value in build_args.items(): + kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) + + logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") + + process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + + # Stream output in real-time + for line in process.stdout: + logging.info(line.strip()) + + process.wait() + + if process.returncode == 0: + logging.info(f"Successfully built {service_name}") + else: + for line in process.stderr: + logging.error(line.strip()) + logging.error(f"Error building {service_name}") + raise Exception(f"Failed to build {service_name}") + +def show_help(): + print(ASCII_ART) + print("EpicMorg: Kaniko-Compose Wrapper\n") + print("Arguments:") + print("--compose-file Path to docker-compose.yml file") + print("--kaniko-image Kaniko executor image") + print("--push, --deploy, -d, -p Deploy the built images to the registry") + print("--dry-run, --dry Dry run: build images without pushing and with cleanup") + print("--version, -v Show script version") + print("--help, -h Show this help message and exit") + +def show_version(): + print(ASCII_ART) + print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") + +def main(): + setup_logging() + + args = parse_args() + + # Show help and exit if --help is provided + if args.help: + show_help() + return + + # Show version and exit if --version or no relevant arguments are provided + if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): + show_version() + return + + compose_file = args.compose_file + kaniko_image = args.kaniko_image + deploy = args.push + dry = args.dry_run + + if not os.path.exists(compose_file): + logging.error(f"{compose_file} not found") + return + + compose_data = load_compose_file(compose_file) + + services = compose_data.get('services', {}) + image_names = defaultdict(int) + + for service_name, service_data in services.items(): + image_name = service_data.get('image') + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + image_names[image_name] += 1 + + for image_name, count in image_names.items(): + if count > 1: + logging.error(f"Error: Image name {image_name} is used {count} times.") + return + + try: + with ThreadPoolExecutor() as executor: + futures = [] + for service_name, service_data in services.items(): + build_data = service_data.get('build', {}) + build_context = build_data.get('context', '.') + dockerfile = build_data.get('dockerfile', 'Dockerfile') + image_name = service_data.get('image') + build_args = build_data.get('args', {}) + + # Substitute environment variables with their values if they exist + build_args = {key: os.getenv(key, value) for key, value in build_args.items()} + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) + + for future in as_completed(futures): + future.result() + except Exception as exc: + logging.error(f"Build failed: {exc}") + sys.exit(1) + +if __name__ == '__main__': + main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.19.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Dockerfile b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Dockerfile new file mode 100644 index 000000000..96896ed42 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Dockerfile @@ -0,0 +1,46 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG BITBUCKET_VERSION=9.0.0 +ARG DOWNLOAD_URL=https://product-downloads.atlassian.com/software/stash/downloads/atlassian-bitbucket-${BITBUCKET_VERSION}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/BitbucketServer/Bitbucket+Server+home+directory +ENV BITBUCKET_HOME /var/atlassian/application-data/bitbucket +ENV BITBUCKET_INSTALL_DIR /opt/atlassian/bitbucket + +VOLUME ["${BITBUCKET_HOME}"] +WORKDIR $BITBUCKET_HOME + +# Expose HTTP and SSH ports +EXPOSE 7990 +EXPOSE 7999 + +################################################################## +# Installing +################################################################## +RUN apt-get update && \ + apt-get install -y --allow-downgrades git/bookworm + +RUN mkdir -p ${BITBUCKET_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "${BITBUCKET_INSTALL_DIR}" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${BITBUCKET_INSTALL_DIR}/ \ + && sed -i -e 's/^# umask/umask/' ${BITBUCKET_INSTALL_DIR}/bin/_start-webapp.sh && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] +COPY entrypoint.sh /entrypoint.sh diff --git a/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Dockerfile.jdk11 b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Dockerfile.jdk11 new file mode 100644 index 000000000..96896ed42 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Dockerfile.jdk11 @@ -0,0 +1,46 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG BITBUCKET_VERSION=9.0.0 +ARG DOWNLOAD_URL=https://product-downloads.atlassian.com/software/stash/downloads/atlassian-bitbucket-${BITBUCKET_VERSION}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/BitbucketServer/Bitbucket+Server+home+directory +ENV BITBUCKET_HOME /var/atlassian/application-data/bitbucket +ENV BITBUCKET_INSTALL_DIR /opt/atlassian/bitbucket + +VOLUME ["${BITBUCKET_HOME}"] +WORKDIR $BITBUCKET_HOME + +# Expose HTTP and SSH ports +EXPOSE 7990 +EXPOSE 7999 + +################################################################## +# Installing +################################################################## +RUN apt-get update && \ + apt-get install -y --allow-downgrades git/bookworm + +RUN mkdir -p ${BITBUCKET_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "${BITBUCKET_INSTALL_DIR}" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${BITBUCKET_INSTALL_DIR}/ \ + && sed -i -e 's/^# umask/umask/' ${BITBUCKET_INSTALL_DIR}/bin/_start-webapp.sh && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] +COPY entrypoint.sh /entrypoint.sh diff --git a/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Dockerfile.jdk17 b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Dockerfile.jdk17 new file mode 100644 index 000000000..c75304fae --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Dockerfile.jdk17 @@ -0,0 +1,46 @@ +FROM epicmorg/debian:bookworm-jdk17 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG BITBUCKET_VERSION=9.0.0 +ARG DOWNLOAD_URL=https://product-downloads.atlassian.com/software/stash/downloads/atlassian-bitbucket-${BITBUCKET_VERSION}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/BitbucketServer/Bitbucket+Server+home+directory +ENV BITBUCKET_HOME /var/atlassian/application-data/bitbucket +ENV BITBUCKET_INSTALL_DIR /opt/atlassian/bitbucket + +VOLUME ["${BITBUCKET_HOME}"] +WORKDIR $BITBUCKET_HOME + +# Expose HTTP and SSH ports +EXPOSE 7990 +EXPOSE 7999 + +################################################################## +# Installing +################################################################## +RUN apt-get update && \ + apt-get install -y --allow-downgrades git/bookworm + +RUN mkdir -p ${BITBUCKET_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "${BITBUCKET_INSTALL_DIR}" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${BITBUCKET_INSTALL_DIR}/ \ + && sed -i -e 's/^# umask/umask/' ${BITBUCKET_INSTALL_DIR}/bin/_start-webapp.sh && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] +COPY entrypoint.sh /entrypoint.sh diff --git a/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Makefile b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Makefile new file mode 100644 index 000000000..3383c9699 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Makefile @@ -0,0 +1,50 @@ +PIP_BREAK_SYSTEM_PACKAGES=1 + +all: app + +app: + make build + make deploy + make clean + +build: + make pip + python3 kaniko-build.py --version + +dry: + make dry-run + +test: + make dry-run + +dry-run: + python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + +pip: + rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.7/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.8/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.12/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.13/EXTERNALLY-MANAGED + pip3 install -r requirements.txt + pip install -r requirements.txt + +build-compose: + docker-compose build --compress --parallel --progress plain + +deploy: + make pip + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + +deploy-compose: + docker-compose push + +clean: + docker container prune -f + docker image prune -f + docker network prune -f + docker volume prune -f + docker system prune -af diff --git a/linux/ecosystem/atlassian/bitbucket/9/9.0.0/README.md b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/README.md new file mode 100644 index 000000000..b60c42068 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/README.md @@ -0,0 +1,216 @@ +![Atlassian Bitbucket Server](https://www.atlassian.com/dam/wac/legacy/bitbucket_logo_landing.png) + +Bitbucket Server is an on-premises source code management solution for Git that's secure, fast, and enterprise grade. Create and manage repositories, set up fine-grained permissions, and collaborate on code - all with the flexibility of your servers. + +Learn more about Bitbucket Server: + +# Overview + +This Docker container makes it easy to get an instance of Bitbucket up and running. + +** We strongly recommend you run this image using a specific version tag instead of latest. This is because the image referenced by the latest tag changes often and we cannot guarantee that it will be backwards compatible. ** + +# Quick Start + +For the `BITBUCKET_HOME` directory that is used to store the repository data +(amongst other things) we recommend mounting a host directory as a [data volume](https://docs.docker.com/engine/tutorials/dockervolumes/#/data-volumes), or via a named volume if using a docker version >= 1.9. + +Volume permission is managed by entry scripts. To get started you can use a data volume, or named volumes. In this example we'll use named volumes. + + $> docker volume create --name bitbucketVolume + $> docker run -v bitbucketVolume:/var/atlassian/application-data/bitbucket --name="bitbucket" -d -p 7990:7990 -p 7999:7999 atlassian/bitbucket-server + +Note that this command can substitute folder paths with named volumes. + +Start Atlassian Bitbucket Server: + + $> docker run -v /data/bitbucket:/var/atlassian/application-data/bitbucket --name="bitbucket" -d -p 7990:7990 -p 7999:7999 atlassian/bitbucket-server + +**Success**. Bitbucket is now available on [http://localhost:7990](http://localhost:7990)* + +Please ensure your container has the necessary resources allocated to it. +We recommend 2GiB of memory allocated to accommodate both the application server +and the git processes. +See [Supported Platforms](https://confluence.atlassian.com/display/BitbucketServer/Supported+platforms) for further information. + + +_* Note: If you are using `docker-machine` on Mac OS X, please use `open http://$(docker-machine ip default):7990` instead._ + +## Reverse Proxy Settings + +If Bitbucket is run behind a reverse proxy server as [described here](https://confluence.atlassian.com/bitbucketserver/proxying-and-securing-bitbucket-server-776640099.html), +then you need to specify extra options to make bitbucket aware of the setup. They can be controlled via the below +environment variables. + +### Bitbucket Server 5.0 + + +Due to the migration to Spring Boot in 5.0, there are changes to how you set up Bitbucket to run behind a reverse proxy. + +In this example, we'll use an environment file. You can also do this via [specifying each environment variable](https://docs.docker.com/engine/reference/run/#env-environment-variables) via the `-e` argument in `docker run`. + +#### secure-bitbucket.env +``` +SERVER_SECURE=true +SERVER_SCHEME=https +SERVER_PROXY_PORT=443 +SERVER_PROXY_NAME= +``` + +Then you run Bitbucket as usual + +`docker run -v bitbucketVolume:/var/atlassian/application-data/bitbucket --name="bitbucket" -d -p 7990:7990 -p 7999:7999 --env-file=/path/to/env/file/secure-bitbucket.env atlassian/bitbucket-server:5.0` + +### Bitbucket Server < 5.0 + +To set the reverse proxy arguments, you specify the following as environment variables in the `docker run` command + +* `CATALINA_CONNECTOR_PROXYNAME` (default: NONE) + + The reverse proxy's fully qualified hostname. + +* `CATALINA_CONNECTOR_PROXYPORT` (default: NONE) + + The reverse proxy's port number via which bitbucket is accessed. + +* `CATALINA_CONNECTOR_SCHEME` (default: http) + + The protocol via which bitbucket is accessed. + +* `CATALINA_CONNECTOR_SECURE` (default: false) + + Set 'true' if CATALINA\_CONNECTOR\_SCHEME is 'https'. + +## JVM Configuration (Bitbucket Server 5.0 + only) + +If you need to override Bitbucket Server's default memory configuration or pass additional JVM arguments, use the environment variables below + +* `JVM_MINIMUM_MEMORY` (default: 512m) + + The minimum heap size of the JVM + +* `JVM_MAXIMUM_MEMORY` (default: 1024m) + + The maximum heap size of the JVM + +* `JVM_SUPPORT_RECOMMENDED_ARGS` (default: NONE) + + Additional JVM arguments for Bitbucket Server, such as a custom Java Trust Store + +## Application Mode Settings (Bitbucket Server 5.0 + only) + +This docker image can be run as a [Smart Mirror](https://confluence.atlassian.com/bitbucketserver/smart-mirroring-776640046.html) or as part of a [Data Center](https://confluence.atlassian.com/enterprise/bitbucket-data-center-668468332.html) cluster. +You can specify the following properties to start Bitbucket as a mirror or as a Data Center node: + +* `ELASTICSEARCH_ENABLED` (default: true) + + Set 'false' to prevent Elasticsearch from starting in the container. This should be used if Elasticsearch is running remotely, e.g. for if Bitbucket is running in a Data Center cluster + +* `APPLICATION_MODE` (default: default) + + The mode Bitbucket will run in. This can be set to 'mirror' to start Bitbucket as a Smart Mirror. This will also disable Elasticsearch even if `ELASTICSEARCH_ENABLED` has not been set to 'false'. + +* `HAZELCAST_NETWORK_MULTICAST` (default: false) + + Data Center: Set 'true' to enable Bitbucket to find new Data Center cluster members via multicast. `HAZELCAST_NETWORK_TCPIP` should not be specified when using this setting. + +* `HAZELCAST_NETWORK_TCPIP` (default: false) + + Data Center: Set 'true' to enable Bitbucket to find new Data Center cluster members via TCPIP. This setting requires `HAZELCAST_NETWORK_TCPIP_MEMBERS` to be specified. `HAZELCAST_NETWORK_MULTICAST` should not be specified when using this setting. + +* `HAZELCAST_NETWORK_TCPIP_MEMBERS` + + Data Center: List of members that Hazelcast nodes should connect to when HAZELCAST_NETWORK_TCPIP is 'true' + +* `HAZELCAST_GROUP_NAME` + + Data Center: Specifies the cluster group the instance should join. + +* `HAZELCAST_GROUP_PASSWORD` + + Data Center: The password required to join the specified cluster group. + +To run Bitbucket as part of a Data Center cluster, create a Docker network and assign the Bitbucket container a static IP. + +Note: Docker networks may support multicast, however the below example shows configuration using TCPIP. + + $> docker network create --driver bridge --subnet=172.18.0.0/16 myBitbucketNetwork + $> docker run --network=myBitbucketNetwork --ip=172.18.1.1 -e ELASTICSEARCH_ENABLED=false \ + -e HAZELCAST_NETWORK_TCPIP=true -e HAZELCAST_NETWORK_TCPIP_MEMBERS=172.18.1.1:5701,172.18.1.2:5701,172.18.1.3:5701 \ + -e HAZELCAST_GROUP_NAME=bitbucket -e HAZELCAST_GROUP_PASSWORD=mysecretpassword \ + -v /data/bitbucket-shared:/var/atlassian/application-data/bitbucket/shared --name="bitbucket" -d -p 7990:7990 -p 7999:7999 atlassian/bitbucket-server + +## JMX Monitoring (Bitbucket Server 5.0 + only) + +Bitbucket Server supports detailed JMX monitoring. To enable and configure JMX, use the environment variables below. For further information on JMX configuration, see [Enabling JMX counters for performance monitoring](https://confluence.atlassian.com/bitbucketserver/enabling-jmx-counters-for-performance-monitoring-776640189.html) + +* `JMX_ENABLED` (default: false) + + Enable Bitbucket to publish JMX data + +* `JMX_REMOTE_AUTH` (default: NONE) + + Set the authentication to use for remote JMX access. This value is required: anything other than "password" or "ssl" will cause remote JMX access to be disabled + +* `JMX_REMOTE_PORT` (default: 3333) + + The port used to negotiate a JMX connection. Note: this port is only used during the initial authorization, after which a different RMI port used for data transfer + +* `JMX_REMOTE_RMI_PORT` (default: ) + + The port used for all subsequent JMX-RMI data transfer. If desired, the RMI data port can be set to the same value as `JMX_REMOTE_PORT` to allow a single port to be used for both JMX authorization and data transfer + +* `RMI_SERVER_HOSTNAME` (default: NONE) + + The hostname or IP address that clients will use to connect to the application for JMX monitoring. This must be resolvable by both clients and from the JVM host machine. + +* `JMX_PASSWORD_FILE` (default: NONE) + + The full path to the JMX username/password file used to authenticate remote JMX clients. This is required when `JMX_REMOTE_AUTH` is set to "password" + + $> docker run -e JMX_ENABLED=true -e JMX_REMOTE_AUTH=password -e JMX_REMOTE_RMI_PORT=3333 -e RMI_SERVER_HOSTNAME=bitbucket \ + -e JMX_PASSWORD_FILE=/data/bitbucket:/var/atlassian/application-data/bitbucket/jmx.access \ + -v /data/bitbucket:/var/atlassian/application-data/bitbucket --name="bitbucket" -d -p 7990:7990 -p 7999:7999 -p 3333:3333 atlassian/bitbucket-server + +# Upgrade + +To upgrade to a more recent version of Bitbucket Server you can simply stop the `bitbucket` +container and start a new one based on a more recent image: + + $> docker stop bitbucket + $> docker rm bitbucket + $> docker pull atlassian/bitbucket-server: + $> docker run ... (See above) + +As your data is stored in the data volume directory on the host it will still +be available after the upgrade. + +_Note: Please make sure that you **don't** accidentally remove the `bitbucket` +container and its volumes using the `-v` option._ + +# Backup + +For evaluations you can use the built-in database that will store its files in the Bitbucket Server home directory. In that case it is sufficient to create a backup archive of the directory on the host that is used as a volume (`/data/bitbucket` in the example above). + +The [Bitbucket Server Backup Client](https://confluence.atlassian.com/display/BitbucketServer/Data+recovery+and+backups) is currently not supported in the Docker setup. You can however use the [Bitbucket Server DIY Backup](https://confluence.atlassian.com/display/BitbucketServer/Using+Bitbucket+Server+DIY+Backup) approach in case you decided to use an external database. + +Read more about data recovery and backups: [https://confluence.atlassian.com/display/BitbucketServer/Data+recovery+and+backups](https://confluence.atlassian.com/display/BitbucketServer/Data+recovery+and+backups) + +# Versioning + +The `latest` tag matches the most recent version of this repository. Thus using `atlassian/bitbucket:latest` or `atlassian/bitbucket` will ensure you are running the most up to date version of this image. + +However, we ** strongly recommend ** that for non-eval workloads you select a specific version in order to prevent breaking changes from impacting your setup. +You can use a specific minor version of Bitbucket Server by using a version number +tag: `atlassian/bitbucket-server:4.14`. This will install the latest `4.14.x` version that +is available. + + +# Issue tracker + +Please raise an [issue](https://bitbucket.org/atlassian/docker-atlassian-bitbucket-server/issues) if you encounter any problems with this Dockerfile. + +# Support + +For product support, go to [support.atlassian.com](https://support.atlassian.com/) +Octotree is enabled on this page. Click this button or press cmd shift s (or ctrl shift s) to show it. +Support us • Feedback? diff --git a/linux/ecosystem/atlassian/bitbucket/9/9.0.0/docker-compose.yml b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/docker-compose.yml new file mode 100644 index 000000000..8f9542bab --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/docker-compose.yml @@ -0,0 +1,16 @@ +#version: '3' +services: + app: + image: "epicmorg/bitbucket:9.0.0" + build: + context: . + app-jdk11: + image: "epicmorg/bitbucket:9.0.0-jdk11" + build: + context: . + dockerfile: ./Dockerfile.jdk11 + app-jdk17: + image: "epicmorg/bitbucket:9.0.0-jdk17" + build: + context: . + dockerfile: ./Dockerfile.jdk17 diff --git a/linux/ecosystem/atlassian/bitbucket/9/9.0.0/entrypoint.sh b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/entrypoint.sh new file mode 100755 index 000000000..842224a8c --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/entrypoint.sh @@ -0,0 +1,57 @@ +#!/bin/bash +set -euo pipefail + +# Set recommended umask of "u=,g=w,o=rwx" (0027) +umask 0027 + +export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") +export JRE_HOME="$JAVA_HOME/jre" +export JAVA_BINARY="$JRE_HOME/bin/java" +export JAVA_VERSION=$("$JAVA_BINARY" -version 2>&1 | awk -F '"' '/version/ {print $2}') + +#export PATH=$JAVA_HOME/bin:$PATH + + +# Setup Catalina Opts +: ${CATALINA_CONNECTOR_PROXYNAME:=} +: ${CATALINA_CONNECTOR_PROXYPORT:=} +: ${CATALINA_CONNECTOR_SCHEME:=http} +: ${CATALINA_CONNECTOR_SECURE:=false} + +: ${CATALINA_OPTS:=} + +: ${JAVA_OPTS:=} + +: ${ELASTICSEARCH_ENABLED:=true} +: ${APPLICATION_MODE:=} + +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyName=${CATALINA_CONNECTOR_PROXYNAME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyPort=${CATALINA_CONNECTOR_PROXYPORT}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorScheme=${CATALINA_CONNECTOR_SCHEME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorSecure=${CATALINA_CONNECTOR_SECURE}" + +JAVA_OPTS="${JAVA_OPTS} ${CATALINA_OPTS}" + +ARGS="$@" + +# Start Bitbucket without Elasticsearch +if [ "${ELASTICSEARCH_ENABLED}" == "false" ] || [ "${APPLICATION_MODE}" == "mirror" ]; then + ARGS="--no-search ${ARGS}" +fi + +# Start Bitbucket as the correct user. +if [ "${UID}" -eq 0 ]; then + echo "User is currently root. Will change directory ownership to ${RUN_USER}:${RUN_GROUP}, then downgrade permission to ${RUN_USER}" + PERMISSIONS_SIGNATURE=$(stat -c "%u:%U:%a" "${BITBUCKET_HOME}") + EXPECTED_PERMISSIONS=$(id -u ${RUN_USER}):${RUN_USER}:700 + if [ "${PERMISSIONS_SIGNATURE}" != "${EXPECTED_PERMISSIONS}" ]; then + echo "Updating permissions for BITBUCKET_HOME" + mkdir -p "${BITBUCKET_HOME}/lib" && + chmod -R 700 "${BITBUCKET_HOME}" && + chown -R "${RUN_USER}:${RUN_GROUP}" "${BITBUCKET_HOME}" + fi + # Now drop privileges + exec su -s /bin/bash "${RUN_USER}" -c "${BITBUCKET_INSTALL_DIR}/bin/start-bitbucket.sh ${ARGS}" +else + exec "${BITBUCKET_INSTALL_DIR}/bin/start-bitbucket.sh" ${ARGS} +fi diff --git a/linux/ecosystem/atlassian/bitbucket/9/9.0.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/kaniko-build.py new file mode 100644 index 000000000..e693b5c17 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/kaniko-build.py @@ -0,0 +1,196 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections import defaultdict +from concurrent.futures import ThreadPoolExecutor, as_completed +from dotenv import load_dotenv +import logging +import sys + +# Script version +SCRIPT_VERSION = "1.0.1.0" + +# ASCII art for EpicMorg +ASCII_ART = r""" ++=================================================+ +| ____| _) \ | | +| __| __ \ | __| |\/ | _ \ __| _` | | +| | | | | ( | | ( | | ( | | +|_____| .__/ _| \___| _| _| \___/ _| \__, | | +| | / _| _) | |___/ | +| ' / _` | __ \ | | / _ \ | +| . \ ( | | | | < ( | | +|_|\_\ \__,_| _| _| _| _|\_\ \___/ | +|\ \ / | +| \ \ \ / __| _` | __ \ __ \ _ \ __|| +| \ \ \ / | ( | | | | | __/ | | +| \_/\_/ _| \__,_| .__/ .__/ \___| _| | +| _| _| | ++=================================================+ +""" + +# Load environment variables from .env file +load_dotenv() + +def setup_logging(): + logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + +def parse_args(): + parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) + parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') + parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') + parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') + parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') + parser.add_argument('--version', '-v', action='store_true', help='Show script version') + parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') + return parser.parse_args() + +def load_compose_file(file_path): + with open(file_path, 'r') as file: + return yaml.safe_load(file) + +def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): + kaniko_command = [ + 'docker', 'run', + '--rm', + '-t', + '-v', f'{os.path.abspath(build_context)}:/workspace', + ] + + # Add Docker config mounts for both read-only access + kaniko_command.extend([ + '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon + '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode + ]) + + kaniko_command.extend([ + kaniko_image, + '--context', '/workspace', + '--dockerfile', f'/workspace/{dockerfile}', + '--compressed-caching', + '--single-snapshot', + '--cleanup' + ]) + + if deploy: + kaniko_command.extend([ + '--destination', image_name + ]) + elif dry: + kaniko_command.extend([ + '--no-push' + ]) + else: + kaniko_command.extend([ + '--no-push' + ]) + + # Add build arguments if they exist + for arg_name, arg_value in build_args.items(): + kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) + + logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") + + process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + + # Stream output in real-time + for line in process.stdout: + logging.info(line.strip()) + + process.wait() + + if process.returncode == 0: + logging.info(f"Successfully built {service_name}") + else: + for line in process.stderr: + logging.error(line.strip()) + logging.error(f"Error building {service_name}") + raise Exception(f"Failed to build {service_name}") + +def show_help(): + print(ASCII_ART) + print("EpicMorg: Kaniko-Compose Wrapper\n") + print("Arguments:") + print("--compose-file Path to docker-compose.yml file") + print("--kaniko-image Kaniko executor image") + print("--push, --deploy, -d, -p Deploy the built images to the registry") + print("--dry-run, --dry Dry run: build images without pushing and with cleanup") + print("--version, -v Show script version") + print("--help, -h Show this help message and exit") + +def show_version(): + print(ASCII_ART) + print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") + +def main(): + setup_logging() + + args = parse_args() + + # Show help and exit if --help is provided + if args.help: + show_help() + return + + # Show version and exit if --version or no relevant arguments are provided + if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): + show_version() + return + + compose_file = args.compose_file + kaniko_image = args.kaniko_image + deploy = args.push + dry = args.dry_run + + if not os.path.exists(compose_file): + logging.error(f"{compose_file} not found") + return + + compose_data = load_compose_file(compose_file) + + services = compose_data.get('services', {}) + image_names = defaultdict(int) + + for service_name, service_data in services.items(): + image_name = service_data.get('image') + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + image_names[image_name] += 1 + + for image_name, count in image_names.items(): + if count > 1: + logging.error(f"Error: Image name {image_name} is used {count} times.") + return + + try: + with ThreadPoolExecutor() as executor: + futures = [] + for service_name, service_data in services.items(): + build_data = service_data.get('build', {}) + build_context = build_data.get('context', '.') + dockerfile = build_data.get('dockerfile', 'Dockerfile') + image_name = service_data.get('image') + build_args = build_data.get('args', {}) + + # Substitute environment variables with their values if they exist + build_args = {key: os.getenv(key, value) for key, value in build_args.items()} + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) + + for future in as_completed(futures): + future.result() + except Exception as exc: + logging.error(f"Build failed: {exc}") + sys.exit(1) + +if __name__ == '__main__': + main() diff --git a/linux/ecosystem/atlassian/bitbucket/9/9.0.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/8/8.8.1/Dockerfile b/linux/ecosystem/atlassian/confluence/8/8.8.1/Dockerfile new file mode 100644 index 000000000..303dc4aa7 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.8.1/Dockerfile @@ -0,0 +1,48 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG RELEASE=8.8.1 +ARG DOWNLOAD_URL=http://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html +ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence +ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence + +VOLUME ["${CONFLUENCE_HOME}"] +WORKDIR $CONFLUENCE_HOME + +# Expose HTTP and Synchrony ports +EXPOSE 8090 +EXPOSE 8091 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${CONFLUENCE_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$CONFLUENCE_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/ \ + && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/port="8090"/port="8090" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/confluence/8/8.8.1/Dockerfile.jdk11 b/linux/ecosystem/atlassian/confluence/8/8.8.1/Dockerfile.jdk11 new file mode 100644 index 000000000..dfa61a420 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.8.1/Dockerfile.jdk11 @@ -0,0 +1,49 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG RELEASE=8.8.1 +ARG DOWNLOAD_URL=http://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html +ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence +ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence + +VOLUME ["${CONFLUENCE_HOME}"] +WORKDIR $CONFLUENCE_HOME + +# Expose HTTP and Synchrony ports +EXPOSE 8090 +EXPOSE 8091 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${CONFLUENCE_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$CONFLUENCE_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/ \ + && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/port="8090"/port="8090" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml && \ + + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/confluence/8/8.8.1/Dockerfile.jdk17 b/linux/ecosystem/atlassian/confluence/8/8.8.1/Dockerfile.jdk17 new file mode 100644 index 000000000..b8bb52274 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.8.1/Dockerfile.jdk17 @@ -0,0 +1,49 @@ +FROM epicmorg/debian:bookworm-jdk17 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG RELEASE=8.8.1 +ARG DOWNLOAD_URL=http://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html +ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence +ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence + +VOLUME ["${CONFLUENCE_HOME}"] +WORKDIR $CONFLUENCE_HOME + +# Expose HTTP and Synchrony ports +EXPOSE 8090 +EXPOSE 8091 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${CONFLUENCE_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$CONFLUENCE_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/ \ + && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/port="8090"/port="8090" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml && \ + + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/confluence/8/8.8.1/Makefile b/linux/ecosystem/atlassian/confluence/8/8.8.1/Makefile new file mode 100644 index 000000000..3383c9699 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.8.1/Makefile @@ -0,0 +1,50 @@ +PIP_BREAK_SYSTEM_PACKAGES=1 + +all: app + +app: + make build + make deploy + make clean + +build: + make pip + python3 kaniko-build.py --version + +dry: + make dry-run + +test: + make dry-run + +dry-run: + python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + +pip: + rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.7/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.8/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.12/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.13/EXTERNALLY-MANAGED + pip3 install -r requirements.txt + pip install -r requirements.txt + +build-compose: + docker-compose build --compress --parallel --progress plain + +deploy: + make pip + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + +deploy-compose: + docker-compose push + +clean: + docker container prune -f + docker image prune -f + docker network prune -f + docker volume prune -f + docker system prune -af diff --git a/linux/ecosystem/atlassian/confluence/8/8.8.1/docker-compose.yml b/linux/ecosystem/atlassian/confluence/8/8.8.1/docker-compose.yml new file mode 100644 index 000000000..8a68e3a0c --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.8.1/docker-compose.yml @@ -0,0 +1,17 @@ +#version: '3' +services: + app: + image: "epicmorg/confluence:8.8.1" + build: + context: . + app-jdk11: + image: "epicmorg/confluence:8.8.1-jdk11" + build: + context: . + dockerfile: Dockerfile.jdk11 + app-jdk17: + image: "epicmorg/confluence:8.8.1-jdk17" + build: + context: . + dockerfile: Dockerfile.jdk17 + diff --git a/linux/ecosystem/atlassian/confluence/8/8.8.1/entrypoint.sh b/linux/ecosystem/atlassian/confluence/8/8.8.1/entrypoint.sh new file mode 100755 index 000000000..250fc031a --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.8.1/entrypoint.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -euo pipefail + +export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") +export JRE_HOME="$JAVA_HOME/jre" +export JAVA_BINARY="$JRE_HOME/bin/java" +export JAVA_VERSION=$("$JAVA_BINARY" -version 2>&1 | awk -F '"' '/version/ {print $2}') + + +# Setup Catalina Opts +: ${CATALINA_CONNECTOR_PROXYNAME:=} +: ${CATALINA_CONNECTOR_PROXYPORT:=} +: ${CATALINA_CONNECTOR_SCHEME:=http} +: ${CATALINA_CONNECTOR_SECURE:=false} + +: ${CATALINA_OPTS:=} + +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyName=${CATALINA_CONNECTOR_PROXYNAME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyPort=${CATALINA_CONNECTOR_PROXYPORT}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorScheme=${CATALINA_CONNECTOR_SCHEME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorSecure=${CATALINA_CONNECTOR_SECURE}" + +export CATALINA_OPTS + + +# Start Confluence as the correct user +if [ "${UID}" -eq 0 ]; then + echo "User is currently root. Will change directory ownership to ${RUN_USER}:${RUN_GROUP}, then downgrade permission to ${RUN_USER}" + PERMISSIONS_SIGNATURE=$(stat -c "%u:%U:%a" "${CONFLUENCE_HOME}") + EXPECTED_PERMISSIONS=$(id -u ${RUN_USER}):${RUN_USER}:700 + if [ "${PERMISSIONS_SIGNATURE}" != "${EXPECTED_PERMISSIONS}" ]; then + chmod -R 700 "${CONFLUENCE_HOME}" && + chown -R "${RUN_USER}:${RUN_GROUP}" "${CONFLUENCE_HOME}" + fi + # Now drop privileges + exec su -s /bin/bash "${RUN_USER}" -c "$CONFLUENCE_INSTALL_DIR/bin/start-confluence.sh $@" +else + exec "$CONFLUENCE_INSTALL_DIR/bin/start-confluence.sh" "$@" +fi diff --git a/linux/ecosystem/atlassian/confluence/8/8.8.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/8/8.8.1/kaniko-build.py new file mode 100644 index 000000000..e693b5c17 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.8.1/kaniko-build.py @@ -0,0 +1,196 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections import defaultdict +from concurrent.futures import ThreadPoolExecutor, as_completed +from dotenv import load_dotenv +import logging +import sys + +# Script version +SCRIPT_VERSION = "1.0.1.0" + +# ASCII art for EpicMorg +ASCII_ART = r""" ++=================================================+ +| ____| _) \ | | +| __| __ \ | __| |\/ | _ \ __| _` | | +| | | | | ( | | ( | | ( | | +|_____| .__/ _| \___| _| _| \___/ _| \__, | | +| | / _| _) | |___/ | +| ' / _` | __ \ | | / _ \ | +| . \ ( | | | | < ( | | +|_|\_\ \__,_| _| _| _| _|\_\ \___/ | +|\ \ / | +| \ \ \ / __| _` | __ \ __ \ _ \ __|| +| \ \ \ / | ( | | | | | __/ | | +| \_/\_/ _| \__,_| .__/ .__/ \___| _| | +| _| _| | ++=================================================+ +""" + +# Load environment variables from .env file +load_dotenv() + +def setup_logging(): + logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + +def parse_args(): + parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) + parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') + parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') + parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') + parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') + parser.add_argument('--version', '-v', action='store_true', help='Show script version') + parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') + return parser.parse_args() + +def load_compose_file(file_path): + with open(file_path, 'r') as file: + return yaml.safe_load(file) + +def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): + kaniko_command = [ + 'docker', 'run', + '--rm', + '-t', + '-v', f'{os.path.abspath(build_context)}:/workspace', + ] + + # Add Docker config mounts for both read-only access + kaniko_command.extend([ + '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon + '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode + ]) + + kaniko_command.extend([ + kaniko_image, + '--context', '/workspace', + '--dockerfile', f'/workspace/{dockerfile}', + '--compressed-caching', + '--single-snapshot', + '--cleanup' + ]) + + if deploy: + kaniko_command.extend([ + '--destination', image_name + ]) + elif dry: + kaniko_command.extend([ + '--no-push' + ]) + else: + kaniko_command.extend([ + '--no-push' + ]) + + # Add build arguments if they exist + for arg_name, arg_value in build_args.items(): + kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) + + logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") + + process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + + # Stream output in real-time + for line in process.stdout: + logging.info(line.strip()) + + process.wait() + + if process.returncode == 0: + logging.info(f"Successfully built {service_name}") + else: + for line in process.stderr: + logging.error(line.strip()) + logging.error(f"Error building {service_name}") + raise Exception(f"Failed to build {service_name}") + +def show_help(): + print(ASCII_ART) + print("EpicMorg: Kaniko-Compose Wrapper\n") + print("Arguments:") + print("--compose-file Path to docker-compose.yml file") + print("--kaniko-image Kaniko executor image") + print("--push, --deploy, -d, -p Deploy the built images to the registry") + print("--dry-run, --dry Dry run: build images without pushing and with cleanup") + print("--version, -v Show script version") + print("--help, -h Show this help message and exit") + +def show_version(): + print(ASCII_ART) + print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") + +def main(): + setup_logging() + + args = parse_args() + + # Show help and exit if --help is provided + if args.help: + show_help() + return + + # Show version and exit if --version or no relevant arguments are provided + if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): + show_version() + return + + compose_file = args.compose_file + kaniko_image = args.kaniko_image + deploy = args.push + dry = args.dry_run + + if not os.path.exists(compose_file): + logging.error(f"{compose_file} not found") + return + + compose_data = load_compose_file(compose_file) + + services = compose_data.get('services', {}) + image_names = defaultdict(int) + + for service_name, service_data in services.items(): + image_name = service_data.get('image') + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + image_names[image_name] += 1 + + for image_name, count in image_names.items(): + if count > 1: + logging.error(f"Error: Image name {image_name} is used {count} times.") + return + + try: + with ThreadPoolExecutor() as executor: + futures = [] + for service_name, service_data in services.items(): + build_data = service_data.get('build', {}) + build_context = build_data.get('context', '.') + dockerfile = build_data.get('dockerfile', 'Dockerfile') + image_name = service_data.get('image') + build_args = build_data.get('args', {}) + + # Substitute environment variables with their values if they exist + build_args = {key: os.getenv(key, value) for key, value in build_args.items()} + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) + + for future in as_completed(futures): + future.result() + except Exception as exc: + logging.error(f"Build failed: {exc}") + sys.exit(1) + +if __name__ == '__main__': + main() diff --git a/linux/ecosystem/atlassian/confluence/8/8.8.1/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.8.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.8.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/8/8.9.5/Dockerfile b/linux/ecosystem/atlassian/confluence/8/8.9.5/Dockerfile new file mode 100644 index 000000000..2c06065b5 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.9.5/Dockerfile @@ -0,0 +1,48 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG RELEASE=8.9.5 +ARG DOWNLOAD_URL=http://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html +ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence +ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence + +VOLUME ["${CONFLUENCE_HOME}"] +WORKDIR $CONFLUENCE_HOME + +# Expose HTTP and Synchrony ports +EXPOSE 8090 +EXPOSE 8091 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${CONFLUENCE_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$CONFLUENCE_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/ \ + && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/port="8090"/port="8090" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/confluence/8/8.9.5/Dockerfile.jdk11 b/linux/ecosystem/atlassian/confluence/8/8.9.5/Dockerfile.jdk11 new file mode 100644 index 000000000..93559b108 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.9.5/Dockerfile.jdk11 @@ -0,0 +1,49 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG RELEASE=8.9.5 +ARG DOWNLOAD_URL=http://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html +ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence +ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence + +VOLUME ["${CONFLUENCE_HOME}"] +WORKDIR $CONFLUENCE_HOME + +# Expose HTTP and Synchrony ports +EXPOSE 8090 +EXPOSE 8091 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${CONFLUENCE_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$CONFLUENCE_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/ \ + && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/port="8090"/port="8090" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml && \ + + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/confluence/8/8.9.5/Dockerfile.jdk17 b/linux/ecosystem/atlassian/confluence/8/8.9.5/Dockerfile.jdk17 new file mode 100644 index 000000000..b5dcedd45 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.9.5/Dockerfile.jdk17 @@ -0,0 +1,49 @@ +FROM epicmorg/debian:bookworm-jdk17 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG RELEASE=8.9.5 +ARG DOWNLOAD_URL=http://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html +ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence +ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence + +VOLUME ["${CONFLUENCE_HOME}"] +WORKDIR $CONFLUENCE_HOME + +# Expose HTTP and Synchrony ports +EXPOSE 8090 +EXPOSE 8091 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${CONFLUENCE_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$CONFLUENCE_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/ \ + && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/port="8090"/port="8090" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml && \ + + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/confluence/8/8.9.5/Makefile b/linux/ecosystem/atlassian/confluence/8/8.9.5/Makefile new file mode 100644 index 000000000..3383c9699 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.9.5/Makefile @@ -0,0 +1,50 @@ +PIP_BREAK_SYSTEM_PACKAGES=1 + +all: app + +app: + make build + make deploy + make clean + +build: + make pip + python3 kaniko-build.py --version + +dry: + make dry-run + +test: + make dry-run + +dry-run: + python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + +pip: + rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.7/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.8/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.12/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.13/EXTERNALLY-MANAGED + pip3 install -r requirements.txt + pip install -r requirements.txt + +build-compose: + docker-compose build --compress --parallel --progress plain + +deploy: + make pip + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + +deploy-compose: + docker-compose push + +clean: + docker container prune -f + docker image prune -f + docker network prune -f + docker volume prune -f + docker system prune -af diff --git a/linux/ecosystem/atlassian/confluence/8/8.9.5/docker-compose.yml b/linux/ecosystem/atlassian/confluence/8/8.9.5/docker-compose.yml new file mode 100644 index 000000000..cd7f25231 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.9.5/docker-compose.yml @@ -0,0 +1,16 @@ +#version: '3' +services: + app: + image: "epicmorg/confluence:8.9.5" + build: + context: . + app-jdk11: + image: "epicmorg/confluence:8.9.5-jdk11" + build: + context: . + dockerfile: Dockerfile.jdk11 + app-jdk17: + image: "epicmorg/confluence:8.9.5-jdk17" + build: + context: . + dockerfile: Dockerfile.jdk17 diff --git a/linux/ecosystem/atlassian/confluence/8/8.9.5/entrypoint.sh b/linux/ecosystem/atlassian/confluence/8/8.9.5/entrypoint.sh new file mode 100755 index 000000000..250fc031a --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.9.5/entrypoint.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -euo pipefail + +export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") +export JRE_HOME="$JAVA_HOME/jre" +export JAVA_BINARY="$JRE_HOME/bin/java" +export JAVA_VERSION=$("$JAVA_BINARY" -version 2>&1 | awk -F '"' '/version/ {print $2}') + + +# Setup Catalina Opts +: ${CATALINA_CONNECTOR_PROXYNAME:=} +: ${CATALINA_CONNECTOR_PROXYPORT:=} +: ${CATALINA_CONNECTOR_SCHEME:=http} +: ${CATALINA_CONNECTOR_SECURE:=false} + +: ${CATALINA_OPTS:=} + +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyName=${CATALINA_CONNECTOR_PROXYNAME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyPort=${CATALINA_CONNECTOR_PROXYPORT}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorScheme=${CATALINA_CONNECTOR_SCHEME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorSecure=${CATALINA_CONNECTOR_SECURE}" + +export CATALINA_OPTS + + +# Start Confluence as the correct user +if [ "${UID}" -eq 0 ]; then + echo "User is currently root. Will change directory ownership to ${RUN_USER}:${RUN_GROUP}, then downgrade permission to ${RUN_USER}" + PERMISSIONS_SIGNATURE=$(stat -c "%u:%U:%a" "${CONFLUENCE_HOME}") + EXPECTED_PERMISSIONS=$(id -u ${RUN_USER}):${RUN_USER}:700 + if [ "${PERMISSIONS_SIGNATURE}" != "${EXPECTED_PERMISSIONS}" ]; then + chmod -R 700 "${CONFLUENCE_HOME}" && + chown -R "${RUN_USER}:${RUN_GROUP}" "${CONFLUENCE_HOME}" + fi + # Now drop privileges + exec su -s /bin/bash "${RUN_USER}" -c "$CONFLUENCE_INSTALL_DIR/bin/start-confluence.sh $@" +else + exec "$CONFLUENCE_INSTALL_DIR/bin/start-confluence.sh" "$@" +fi diff --git a/linux/ecosystem/atlassian/confluence/8/8.9.5/kaniko-build.py b/linux/ecosystem/atlassian/confluence/8/8.9.5/kaniko-build.py new file mode 100644 index 000000000..e693b5c17 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.9.5/kaniko-build.py @@ -0,0 +1,196 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections import defaultdict +from concurrent.futures import ThreadPoolExecutor, as_completed +from dotenv import load_dotenv +import logging +import sys + +# Script version +SCRIPT_VERSION = "1.0.1.0" + +# ASCII art for EpicMorg +ASCII_ART = r""" ++=================================================+ +| ____| _) \ | | +| __| __ \ | __| |\/ | _ \ __| _` | | +| | | | | ( | | ( | | ( | | +|_____| .__/ _| \___| _| _| \___/ _| \__, | | +| | / _| _) | |___/ | +| ' / _` | __ \ | | / _ \ | +| . \ ( | | | | < ( | | +|_|\_\ \__,_| _| _| _| _|\_\ \___/ | +|\ \ / | +| \ \ \ / __| _` | __ \ __ \ _ \ __|| +| \ \ \ / | ( | | | | | __/ | | +| \_/\_/ _| \__,_| .__/ .__/ \___| _| | +| _| _| | ++=================================================+ +""" + +# Load environment variables from .env file +load_dotenv() + +def setup_logging(): + logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + +def parse_args(): + parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) + parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') + parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') + parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') + parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') + parser.add_argument('--version', '-v', action='store_true', help='Show script version') + parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') + return parser.parse_args() + +def load_compose_file(file_path): + with open(file_path, 'r') as file: + return yaml.safe_load(file) + +def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): + kaniko_command = [ + 'docker', 'run', + '--rm', + '-t', + '-v', f'{os.path.abspath(build_context)}:/workspace', + ] + + # Add Docker config mounts for both read-only access + kaniko_command.extend([ + '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon + '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode + ]) + + kaniko_command.extend([ + kaniko_image, + '--context', '/workspace', + '--dockerfile', f'/workspace/{dockerfile}', + '--compressed-caching', + '--single-snapshot', + '--cleanup' + ]) + + if deploy: + kaniko_command.extend([ + '--destination', image_name + ]) + elif dry: + kaniko_command.extend([ + '--no-push' + ]) + else: + kaniko_command.extend([ + '--no-push' + ]) + + # Add build arguments if they exist + for arg_name, arg_value in build_args.items(): + kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) + + logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") + + process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + + # Stream output in real-time + for line in process.stdout: + logging.info(line.strip()) + + process.wait() + + if process.returncode == 0: + logging.info(f"Successfully built {service_name}") + else: + for line in process.stderr: + logging.error(line.strip()) + logging.error(f"Error building {service_name}") + raise Exception(f"Failed to build {service_name}") + +def show_help(): + print(ASCII_ART) + print("EpicMorg: Kaniko-Compose Wrapper\n") + print("Arguments:") + print("--compose-file Path to docker-compose.yml file") + print("--kaniko-image Kaniko executor image") + print("--push, --deploy, -d, -p Deploy the built images to the registry") + print("--dry-run, --dry Dry run: build images without pushing and with cleanup") + print("--version, -v Show script version") + print("--help, -h Show this help message and exit") + +def show_version(): + print(ASCII_ART) + print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") + +def main(): + setup_logging() + + args = parse_args() + + # Show help and exit if --help is provided + if args.help: + show_help() + return + + # Show version and exit if --version or no relevant arguments are provided + if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): + show_version() + return + + compose_file = args.compose_file + kaniko_image = args.kaniko_image + deploy = args.push + dry = args.dry_run + + if not os.path.exists(compose_file): + logging.error(f"{compose_file} not found") + return + + compose_data = load_compose_file(compose_file) + + services = compose_data.get('services', {}) + image_names = defaultdict(int) + + for service_name, service_data in services.items(): + image_name = service_data.get('image') + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + image_names[image_name] += 1 + + for image_name, count in image_names.items(): + if count > 1: + logging.error(f"Error: Image name {image_name} is used {count} times.") + return + + try: + with ThreadPoolExecutor() as executor: + futures = [] + for service_name, service_data in services.items(): + build_data = service_data.get('build', {}) + build_context = build_data.get('context', '.') + dockerfile = build_data.get('dockerfile', 'Dockerfile') + image_name = service_data.get('image') + build_args = build_data.get('args', {}) + + # Substitute environment variables with their values if they exist + build_args = {key: os.getenv(key, value) for key, value in build_args.items()} + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) + + for future in as_completed(futures): + future.result() + except Exception as exc: + logging.error(f"Build failed: {exc}") + sys.exit(1) + +if __name__ == '__main__': + main() diff --git a/linux/ecosystem/atlassian/confluence/8/8.9.5/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.9.5/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/8/8.9.5/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.0/Dockerfile b/linux/ecosystem/atlassian/confluence/9/9.0.0/Dockerfile new file mode 100644 index 000000000..9f6b62d92 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.0/Dockerfile @@ -0,0 +1,48 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG RELEASE=9.0.0 +ARG DOWNLOAD_URL=http://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html +ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence +ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence + +VOLUME ["${CONFLUENCE_HOME}"] +WORKDIR $CONFLUENCE_HOME + +# Expose HTTP and Synchrony ports +EXPOSE 8090 +EXPOSE 8091 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${CONFLUENCE_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$CONFLUENCE_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/ \ + && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/port="8090"/port="8090" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.0/Dockerfile.jdk11 b/linux/ecosystem/atlassian/confluence/9/9.0.0/Dockerfile.jdk11 new file mode 100644 index 000000000..dd19c0012 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.0/Dockerfile.jdk11 @@ -0,0 +1,49 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG RELEASE=9.0.0 +ARG DOWNLOAD_URL=http://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html +ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence +ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence + +VOLUME ["${CONFLUENCE_HOME}"] +WORKDIR $CONFLUENCE_HOME + +# Expose HTTP and Synchrony ports +EXPOSE 8090 +EXPOSE 8091 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${CONFLUENCE_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$CONFLUENCE_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/ \ + && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/port="8090"/port="8090" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml && \ + + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.0/Dockerfile.jdk17 b/linux/ecosystem/atlassian/confluence/9/9.0.0/Dockerfile.jdk17 new file mode 100644 index 000000000..90e6e52de --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.0/Dockerfile.jdk17 @@ -0,0 +1,49 @@ +FROM epicmorg/debian:bookworm-jdk17 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG RELEASE=9.0.0 +ARG DOWNLOAD_URL=http://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html +ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence +ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence + +VOLUME ["${CONFLUENCE_HOME}"] +WORKDIR $CONFLUENCE_HOME + +# Expose HTTP and Synchrony ports +EXPOSE 8090 +EXPOSE 8091 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${CONFLUENCE_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$CONFLUENCE_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/ \ + && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/port="8090"/port="8090" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml && \ + + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.0/Makefile b/linux/ecosystem/atlassian/confluence/9/9.0.0/Makefile new file mode 100644 index 000000000..3383c9699 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.0/Makefile @@ -0,0 +1,50 @@ +PIP_BREAK_SYSTEM_PACKAGES=1 + +all: app + +app: + make build + make deploy + make clean + +build: + make pip + python3 kaniko-build.py --version + +dry: + make dry-run + +test: + make dry-run + +dry-run: + python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + +pip: + rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.7/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.8/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.12/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.13/EXTERNALLY-MANAGED + pip3 install -r requirements.txt + pip install -r requirements.txt + +build-compose: + docker-compose build --compress --parallel --progress plain + +deploy: + make pip + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + +deploy-compose: + docker-compose push + +clean: + docker container prune -f + docker image prune -f + docker network prune -f + docker volume prune -f + docker system prune -af diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.0/docker-compose.yml b/linux/ecosystem/atlassian/confluence/9/9.0.0/docker-compose.yml new file mode 100644 index 000000000..b3addbe4d --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.0/docker-compose.yml @@ -0,0 +1,16 @@ +#version: '3' +services: + app: + image: "epicmorg/confluence:9.0.0" + build: + context: . + app-jdk11: + image: "epicmorg/confluence:9.0.0-jdk11" + build: + context: . + dockerfile: Dockerfile.jdk11 + app-jdk17: + image: "epicmorg/confluence:9.0.0-jdk17" + build: + context: . + dockerfile: Dockerfile.jdk17 diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.0/entrypoint.sh b/linux/ecosystem/atlassian/confluence/9/9.0.0/entrypoint.sh new file mode 100755 index 000000000..250fc031a --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.0/entrypoint.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -euo pipefail + +export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") +export JRE_HOME="$JAVA_HOME/jre" +export JAVA_BINARY="$JRE_HOME/bin/java" +export JAVA_VERSION=$("$JAVA_BINARY" -version 2>&1 | awk -F '"' '/version/ {print $2}') + + +# Setup Catalina Opts +: ${CATALINA_CONNECTOR_PROXYNAME:=} +: ${CATALINA_CONNECTOR_PROXYPORT:=} +: ${CATALINA_CONNECTOR_SCHEME:=http} +: ${CATALINA_CONNECTOR_SECURE:=false} + +: ${CATALINA_OPTS:=} + +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyName=${CATALINA_CONNECTOR_PROXYNAME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyPort=${CATALINA_CONNECTOR_PROXYPORT}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorScheme=${CATALINA_CONNECTOR_SCHEME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorSecure=${CATALINA_CONNECTOR_SECURE}" + +export CATALINA_OPTS + + +# Start Confluence as the correct user +if [ "${UID}" -eq 0 ]; then + echo "User is currently root. Will change directory ownership to ${RUN_USER}:${RUN_GROUP}, then downgrade permission to ${RUN_USER}" + PERMISSIONS_SIGNATURE=$(stat -c "%u:%U:%a" "${CONFLUENCE_HOME}") + EXPECTED_PERMISSIONS=$(id -u ${RUN_USER}):${RUN_USER}:700 + if [ "${PERMISSIONS_SIGNATURE}" != "${EXPECTED_PERMISSIONS}" ]; then + chmod -R 700 "${CONFLUENCE_HOME}" && + chown -R "${RUN_USER}:${RUN_GROUP}" "${CONFLUENCE_HOME}" + fi + # Now drop privileges + exec su -s /bin/bash "${RUN_USER}" -c "$CONFLUENCE_INSTALL_DIR/bin/start-confluence.sh $@" +else + exec "$CONFLUENCE_INSTALL_DIR/bin/start-confluence.sh" "$@" +fi diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/9/9.0.0/kaniko-build.py new file mode 100644 index 000000000..e693b5c17 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.0/kaniko-build.py @@ -0,0 +1,196 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections import defaultdict +from concurrent.futures import ThreadPoolExecutor, as_completed +from dotenv import load_dotenv +import logging +import sys + +# Script version +SCRIPT_VERSION = "1.0.1.0" + +# ASCII art for EpicMorg +ASCII_ART = r""" ++=================================================+ +| ____| _) \ | | +| __| __ \ | __| |\/ | _ \ __| _` | | +| | | | | ( | | ( | | ( | | +|_____| .__/ _| \___| _| _| \___/ _| \__, | | +| | / _| _) | |___/ | +| ' / _` | __ \ | | / _ \ | +| . \ ( | | | | < ( | | +|_|\_\ \__,_| _| _| _| _|\_\ \___/ | +|\ \ / | +| \ \ \ / __| _` | __ \ __ \ _ \ __|| +| \ \ \ / | ( | | | | | __/ | | +| \_/\_/ _| \__,_| .__/ .__/ \___| _| | +| _| _| | ++=================================================+ +""" + +# Load environment variables from .env file +load_dotenv() + +def setup_logging(): + logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + +def parse_args(): + parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) + parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') + parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') + parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') + parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') + parser.add_argument('--version', '-v', action='store_true', help='Show script version') + parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') + return parser.parse_args() + +def load_compose_file(file_path): + with open(file_path, 'r') as file: + return yaml.safe_load(file) + +def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): + kaniko_command = [ + 'docker', 'run', + '--rm', + '-t', + '-v', f'{os.path.abspath(build_context)}:/workspace', + ] + + # Add Docker config mounts for both read-only access + kaniko_command.extend([ + '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon + '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode + ]) + + kaniko_command.extend([ + kaniko_image, + '--context', '/workspace', + '--dockerfile', f'/workspace/{dockerfile}', + '--compressed-caching', + '--single-snapshot', + '--cleanup' + ]) + + if deploy: + kaniko_command.extend([ + '--destination', image_name + ]) + elif dry: + kaniko_command.extend([ + '--no-push' + ]) + else: + kaniko_command.extend([ + '--no-push' + ]) + + # Add build arguments if they exist + for arg_name, arg_value in build_args.items(): + kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) + + logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") + + process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + + # Stream output in real-time + for line in process.stdout: + logging.info(line.strip()) + + process.wait() + + if process.returncode == 0: + logging.info(f"Successfully built {service_name}") + else: + for line in process.stderr: + logging.error(line.strip()) + logging.error(f"Error building {service_name}") + raise Exception(f"Failed to build {service_name}") + +def show_help(): + print(ASCII_ART) + print("EpicMorg: Kaniko-Compose Wrapper\n") + print("Arguments:") + print("--compose-file Path to docker-compose.yml file") + print("--kaniko-image Kaniko executor image") + print("--push, --deploy, -d, -p Deploy the built images to the registry") + print("--dry-run, --dry Dry run: build images without pushing and with cleanup") + print("--version, -v Show script version") + print("--help, -h Show this help message and exit") + +def show_version(): + print(ASCII_ART) + print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") + +def main(): + setup_logging() + + args = parse_args() + + # Show help and exit if --help is provided + if args.help: + show_help() + return + + # Show version and exit if --version or no relevant arguments are provided + if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): + show_version() + return + + compose_file = args.compose_file + kaniko_image = args.kaniko_image + deploy = args.push + dry = args.dry_run + + if not os.path.exists(compose_file): + logging.error(f"{compose_file} not found") + return + + compose_data = load_compose_file(compose_file) + + services = compose_data.get('services', {}) + image_names = defaultdict(int) + + for service_name, service_data in services.items(): + image_name = service_data.get('image') + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + image_names[image_name] += 1 + + for image_name, count in image_names.items(): + if count > 1: + logging.error(f"Error: Image name {image_name} is used {count} times.") + return + + try: + with ThreadPoolExecutor() as executor: + futures = [] + for service_name, service_data in services.items(): + build_data = service_data.get('build', {}) + build_context = build_data.get('context', '.') + dockerfile = build_data.get('dockerfile', 'Dockerfile') + image_name = service_data.get('image') + build_args = build_data.get('args', {}) + + # Substitute environment variables with their values if they exist + build_args = {key: os.getenv(key, value) for key, value in build_args.items()} + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) + + for future in as_completed(futures): + future.result() + except Exception as exc: + logging.error(f"Build failed: {exc}") + sys.exit(1) + +if __name__ == '__main__': + main() diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.0/requirements.txt b/linux/ecosystem/atlassian/confluence/9/9.0.0/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.0/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.1/Dockerfile b/linux/ecosystem/atlassian/confluence/9/9.0.1/Dockerfile new file mode 100644 index 000000000..9c2ca5070 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.1/Dockerfile @@ -0,0 +1,48 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG RELEASE=9.0.1 +ARG DOWNLOAD_URL=http://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html +ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence +ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence + +VOLUME ["${CONFLUENCE_HOME}"] +WORKDIR $CONFLUENCE_HOME + +# Expose HTTP and Synchrony ports +EXPOSE 8090 +EXPOSE 8091 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${CONFLUENCE_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$CONFLUENCE_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/ \ + && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/port="8090"/port="8090" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.1/Dockerfile.jdk11 b/linux/ecosystem/atlassian/confluence/9/9.0.1/Dockerfile.jdk11 new file mode 100644 index 000000000..1c09826f8 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.1/Dockerfile.jdk11 @@ -0,0 +1,49 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG RELEASE=9.0.1 +ARG DOWNLOAD_URL=http://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html +ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence +ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence + +VOLUME ["${CONFLUENCE_HOME}"] +WORKDIR $CONFLUENCE_HOME + +# Expose HTTP and Synchrony ports +EXPOSE 8090 +EXPOSE 8091 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${CONFLUENCE_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$CONFLUENCE_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/ \ + && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/port="8090"/port="8090" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml && \ + + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.1/Dockerfile.jdk17 b/linux/ecosystem/atlassian/confluence/9/9.0.1/Dockerfile.jdk17 new file mode 100644 index 000000000..281d87a32 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.1/Dockerfile.jdk17 @@ -0,0 +1,49 @@ +FROM epicmorg/debian:bookworm-jdk17 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## +ARG RELEASE=9.0.1 +ARG DOWNLOAD_URL=http://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html +ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence +ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence + +VOLUME ["${CONFLUENCE_HOME}"] +WORKDIR $CONFLUENCE_HOME + +# Expose HTTP and Synchrony ports +EXPOSE 8090 +EXPOSE 8091 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${CONFLUENCE_INSTALL_DIR} \ + && curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$CONFLUENCE_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/ \ + && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/port="8090"/port="8090" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml && \ + + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.1/Makefile b/linux/ecosystem/atlassian/confluence/9/9.0.1/Makefile new file mode 100644 index 000000000..3383c9699 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.1/Makefile @@ -0,0 +1,50 @@ +PIP_BREAK_SYSTEM_PACKAGES=1 + +all: app + +app: + make build + make deploy + make clean + +build: + make pip + python3 kaniko-build.py --version + +dry: + make dry-run + +test: + make dry-run + +dry-run: + python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + +pip: + rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.7/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.8/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.12/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.13/EXTERNALLY-MANAGED + pip3 install -r requirements.txt + pip install -r requirements.txt + +build-compose: + docker-compose build --compress --parallel --progress plain + +deploy: + make pip + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + +deploy-compose: + docker-compose push + +clean: + docker container prune -f + docker image prune -f + docker network prune -f + docker volume prune -f + docker system prune -af diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.1/docker-compose.yml b/linux/ecosystem/atlassian/confluence/9/9.0.1/docker-compose.yml new file mode 100644 index 000000000..08b7c3911 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.1/docker-compose.yml @@ -0,0 +1,16 @@ +#version: '3' +services: + app: + image: "epicmorg/confluence:9.0.1" + build: + context: . + app-jdk11: + image: "epicmorg/confluence:9.0.1-jdk11" + build: + context: . + dockerfile: Dockerfile.jdk11 + app-jdk17: + image: "epicmorg/confluence:9.0.1-jdk17" + build: + context: . + dockerfile: Dockerfile.jdk17 diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.1/entrypoint.sh b/linux/ecosystem/atlassian/confluence/9/9.0.1/entrypoint.sh new file mode 100755 index 000000000..250fc031a --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.1/entrypoint.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -euo pipefail + +export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") +export JRE_HOME="$JAVA_HOME/jre" +export JAVA_BINARY="$JRE_HOME/bin/java" +export JAVA_VERSION=$("$JAVA_BINARY" -version 2>&1 | awk -F '"' '/version/ {print $2}') + + +# Setup Catalina Opts +: ${CATALINA_CONNECTOR_PROXYNAME:=} +: ${CATALINA_CONNECTOR_PROXYPORT:=} +: ${CATALINA_CONNECTOR_SCHEME:=http} +: ${CATALINA_CONNECTOR_SECURE:=false} + +: ${CATALINA_OPTS:=} + +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyName=${CATALINA_CONNECTOR_PROXYNAME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyPort=${CATALINA_CONNECTOR_PROXYPORT}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorScheme=${CATALINA_CONNECTOR_SCHEME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorSecure=${CATALINA_CONNECTOR_SECURE}" + +export CATALINA_OPTS + + +# Start Confluence as the correct user +if [ "${UID}" -eq 0 ]; then + echo "User is currently root. Will change directory ownership to ${RUN_USER}:${RUN_GROUP}, then downgrade permission to ${RUN_USER}" + PERMISSIONS_SIGNATURE=$(stat -c "%u:%U:%a" "${CONFLUENCE_HOME}") + EXPECTED_PERMISSIONS=$(id -u ${RUN_USER}):${RUN_USER}:700 + if [ "${PERMISSIONS_SIGNATURE}" != "${EXPECTED_PERMISSIONS}" ]; then + chmod -R 700 "${CONFLUENCE_HOME}" && + chown -R "${RUN_USER}:${RUN_GROUP}" "${CONFLUENCE_HOME}" + fi + # Now drop privileges + exec su -s /bin/bash "${RUN_USER}" -c "$CONFLUENCE_INSTALL_DIR/bin/start-confluence.sh $@" +else + exec "$CONFLUENCE_INSTALL_DIR/bin/start-confluence.sh" "$@" +fi diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/9/9.0.1/kaniko-build.py new file mode 100644 index 000000000..e693b5c17 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.1/kaniko-build.py @@ -0,0 +1,196 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections import defaultdict +from concurrent.futures import ThreadPoolExecutor, as_completed +from dotenv import load_dotenv +import logging +import sys + +# Script version +SCRIPT_VERSION = "1.0.1.0" + +# ASCII art for EpicMorg +ASCII_ART = r""" ++=================================================+ +| ____| _) \ | | +| __| __ \ | __| |\/ | _ \ __| _` | | +| | | | | ( | | ( | | ( | | +|_____| .__/ _| \___| _| _| \___/ _| \__, | | +| | / _| _) | |___/ | +| ' / _` | __ \ | | / _ \ | +| . \ ( | | | | < ( | | +|_|\_\ \__,_| _| _| _| _|\_\ \___/ | +|\ \ / | +| \ \ \ / __| _` | __ \ __ \ _ \ __|| +| \ \ \ / | ( | | | | | __/ | | +| \_/\_/ _| \__,_| .__/ .__/ \___| _| | +| _| _| | ++=================================================+ +""" + +# Load environment variables from .env file +load_dotenv() + +def setup_logging(): + logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + +def parse_args(): + parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) + parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') + parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') + parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') + parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') + parser.add_argument('--version', '-v', action='store_true', help='Show script version') + parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') + return parser.parse_args() + +def load_compose_file(file_path): + with open(file_path, 'r') as file: + return yaml.safe_load(file) + +def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): + kaniko_command = [ + 'docker', 'run', + '--rm', + '-t', + '-v', f'{os.path.abspath(build_context)}:/workspace', + ] + + # Add Docker config mounts for both read-only access + kaniko_command.extend([ + '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon + '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode + ]) + + kaniko_command.extend([ + kaniko_image, + '--context', '/workspace', + '--dockerfile', f'/workspace/{dockerfile}', + '--compressed-caching', + '--single-snapshot', + '--cleanup' + ]) + + if deploy: + kaniko_command.extend([ + '--destination', image_name + ]) + elif dry: + kaniko_command.extend([ + '--no-push' + ]) + else: + kaniko_command.extend([ + '--no-push' + ]) + + # Add build arguments if they exist + for arg_name, arg_value in build_args.items(): + kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) + + logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") + + process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + + # Stream output in real-time + for line in process.stdout: + logging.info(line.strip()) + + process.wait() + + if process.returncode == 0: + logging.info(f"Successfully built {service_name}") + else: + for line in process.stderr: + logging.error(line.strip()) + logging.error(f"Error building {service_name}") + raise Exception(f"Failed to build {service_name}") + +def show_help(): + print(ASCII_ART) + print("EpicMorg: Kaniko-Compose Wrapper\n") + print("Arguments:") + print("--compose-file Path to docker-compose.yml file") + print("--kaniko-image Kaniko executor image") + print("--push, --deploy, -d, -p Deploy the built images to the registry") + print("--dry-run, --dry Dry run: build images without pushing and with cleanup") + print("--version, -v Show script version") + print("--help, -h Show this help message and exit") + +def show_version(): + print(ASCII_ART) + print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") + +def main(): + setup_logging() + + args = parse_args() + + # Show help and exit if --help is provided + if args.help: + show_help() + return + + # Show version and exit if --version or no relevant arguments are provided + if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): + show_version() + return + + compose_file = args.compose_file + kaniko_image = args.kaniko_image + deploy = args.push + dry = args.dry_run + + if not os.path.exists(compose_file): + logging.error(f"{compose_file} not found") + return + + compose_data = load_compose_file(compose_file) + + services = compose_data.get('services', {}) + image_names = defaultdict(int) + + for service_name, service_data in services.items(): + image_name = service_data.get('image') + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + image_names[image_name] += 1 + + for image_name, count in image_names.items(): + if count > 1: + logging.error(f"Error: Image name {image_name} is used {count} times.") + return + + try: + with ThreadPoolExecutor() as executor: + futures = [] + for service_name, service_data in services.items(): + build_data = service_data.get('build', {}) + build_context = build_data.get('context', '.') + dockerfile = build_data.get('dockerfile', 'Dockerfile') + image_name = service_data.get('image') + build_args = build_data.get('args', {}) + + # Substitute environment variables with their values if they exist + build_args = {key: os.getenv(key, value) for key, value in build_args.items()} + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) + + for future in as_completed(futures): + future.result() + except Exception as exc: + logging.error(f"Build failed: {exc}") + sys.exit(1) + +if __name__ == '__main__': + main() diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.1/requirements.txt b/linux/ecosystem/atlassian/confluence/9/9.0.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/confluence/9/9.0.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.12.12/Dockerfile b/linux/ecosystem/atlassian/jira/9/9.12.12/Dockerfile new file mode 100644 index 000000000..cfbeaa2b8 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.12.12/Dockerfile @@ -0,0 +1,53 @@ +FROM epicmorg/debian:bookworm-jdk8 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## + +ARG RELEASE=9.12.12 +ARG DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/JSERVERM/Important+directories+and+files +ENV JIRA_HOME /var/atlassian/application-data/jira +ENV JIRA_INSTALL_DIR /opt/atlassian/jira + +VOLUME ["${JIRA_HOME}"] +WORKDIR $JIRA_HOME + +# Expose HTTP port +EXPOSE 8080 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${JIRA_INSTALL_DIR} \ + && wget --random-wait --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36" -P /tmp/ ${DOWNLOAD_URL} \ + && tar -xzf /tmp/atlassian-jira-software-${RELEASE}.tar.gz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \ + && sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/grep "java version"/grep -E "(openjdk|java) version"/g' ${JIRA_INSTALL_DIR}/bin/check-java.sh \ + && sed -i -e 's/port="8080"/port="8080" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${JIRA_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb && \ + rm -rfv /tmp/* + + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/jira/9/9.12.12/Dockerfile.jdk11 b/linux/ecosystem/atlassian/jira/9/9.12.12/Dockerfile.jdk11 new file mode 100644 index 000000000..a0d16cdb7 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.12.12/Dockerfile.jdk11 @@ -0,0 +1,52 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## + +ARG RELEASE=9.12.12 +ARG DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/JSERVERM/Important+directories+and+files +ENV JIRA_HOME /var/atlassian/application-data/jira +ENV JIRA_INSTALL_DIR /opt/atlassian/jira + +VOLUME ["${JIRA_HOME}"] +WORKDIR $JIRA_HOME + +# Expose HTTP port +EXPOSE 8080 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${JIRA_INSTALL_DIR} \ + && wget --random-wait --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36" -P /tmp/ ${DOWNLOAD_URL} \ + && tar -xzf /tmp/atlassian-jira-software-${RELEASE}.tar.gz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \ + && sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/grep "java version"/grep -E "(openjdk|java) version"/g' ${JIRA_INSTALL_DIR}/bin/check-java.sh \ + && sed -i -e 's/port="8080"/port="8080" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${JIRA_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb && \ + rm -rfv /tmp/* + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/jira/9/9.12.12/Dockerfile.jdk17 b/linux/ecosystem/atlassian/jira/9/9.12.12/Dockerfile.jdk17 new file mode 100644 index 000000000..a5d7e379c --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.12.12/Dockerfile.jdk17 @@ -0,0 +1,52 @@ +FROM epicmorg/debian:bookworm-jdk17 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## + +ARG RELEASE=9.12.12 +ARG DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/JSERVERM/Important+directories+and+files +ENV JIRA_HOME /var/atlassian/application-data/jira +ENV JIRA_INSTALL_DIR /opt/atlassian/jira + +VOLUME ["${JIRA_HOME}"] +WORKDIR $JIRA_HOME + +# Expose HTTP port +EXPOSE 8080 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${JIRA_INSTALL_DIR} \ + && wget --random-wait --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36" -P /tmp/ ${DOWNLOAD_URL} \ + && tar -xzf /tmp/atlassian-jira-software-${RELEASE}.tar.gz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \ + && sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/grep "java version"/grep -E "(openjdk|java) version"/g' ${JIRA_INSTALL_DIR}/bin/check-java.sh \ + && sed -i -e 's/port="8080"/port="8080" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${JIRA_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb && \ + rm -rfv /tmp/* + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/jira/9/9.12.12/Makefile b/linux/ecosystem/atlassian/jira/9/9.12.12/Makefile new file mode 100644 index 000000000..3383c9699 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.12.12/Makefile @@ -0,0 +1,50 @@ +PIP_BREAK_SYSTEM_PACKAGES=1 + +all: app + +app: + make build + make deploy + make clean + +build: + make pip + python3 kaniko-build.py --version + +dry: + make dry-run + +test: + make dry-run + +dry-run: + python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + +pip: + rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.7/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.8/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.12/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.13/EXTERNALLY-MANAGED + pip3 install -r requirements.txt + pip install -r requirements.txt + +build-compose: + docker-compose build --compress --parallel --progress plain + +deploy: + make pip + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + +deploy-compose: + docker-compose push + +clean: + docker container prune -f + docker image prune -f + docker network prune -f + docker volume prune -f + docker system prune -af diff --git a/linux/ecosystem/atlassian/jira/9/9.12.12/docker-compose.yml b/linux/ecosystem/atlassian/jira/9/9.12.12/docker-compose.yml new file mode 100644 index 000000000..90b0a227d --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.12.12/docker-compose.yml @@ -0,0 +1,16 @@ +#version: '3' +services: + app: + image: "epicmorg/jira:9.12.12" + build: + context: . + app-jdk11: + image: "epicmorg/jira:9.12.12-jdk11" + build: + context: . + dockerfile: Dockerfile.jdk11 + app-jdk17: + image: "epicmorg/jira:9.12.12-jdk17" + build: + context: . + dockerfile: Dockerfile.jdk17 diff --git a/linux/ecosystem/atlassian/jira/9/9.12.12/entrypoint.sh b/linux/ecosystem/atlassian/jira/9/9.12.12/entrypoint.sh new file mode 100755 index 000000000..50ee4ecd1 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.12.12/entrypoint.sh @@ -0,0 +1,89 @@ +#!/bin/bash +set -euo pipefail + +export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") +export JRE_HOME="$JAVA_HOME/jre" +export JAVA_BINARY="$JRE_HOME/bin/java" +export JAVA_VERSION=$("$JAVA_BINARY" -version 2>&1 | awk -F '"' '/version/ {print $2}') + +# Setup Catalina Opts +: ${CATALINA_CONNECTOR_PROXYNAME:=} +: ${CATALINA_CONNECTOR_PROXYPORT:=} +: ${CATALINA_CONNECTOR_SCHEME:=http} +: ${CATALINA_CONNECTOR_SECURE:=false} + +: ${CATALINA_OPTS:=} + +: ${JAVA_OPTS:=} + +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyName=${CATALINA_CONNECTOR_PROXYNAME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyPort=${CATALINA_CONNECTOR_PROXYPORT}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorScheme=${CATALINA_CONNECTOR_SCHEME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorSecure=${CATALINA_CONNECTOR_SECURE}" + +export JAVA_OPTS="${JAVA_OPTS} ${CATALINA_OPTS}" + +# Setup Data Center configuration +if [ ! -f "/etc/container_id" ]; then + uuidgen > /etc/container_id +fi +CONTAINER_ID=$(cat /etc/container_id) +CONTAINER_SHORT_ID=${CONTAINER_ID::8} + +: ${CLUSTERED:=false} +: ${JIRA_NODE_ID:=jira_node_${CONTAINER_SHORT_ID}} +: ${JIRA_SHARED_HOME:=${JIRA_HOME}/shared} +: ${EHCACHE_PEER_DISCOVERY:=} +: ${EHCACHE_LISTENER_HOSTNAME:=} +: ${EHCACHE_LISTENER_PORT:=} +: ${EHCACHE_LISTENER_SOCKETTIMEOUTMILLIS:=} +: ${EHCACHE_MULTICAST_ADDRESS:=} +: ${EHCACHE_MULTICAST_PORT:=} +: ${EHCACHE_MULTICAST_TIMETOLIVE:=} +: ${EHCACHE_MULTICAST_HOSTNAME:=} + +# Cleanly set/unset values in cluster.properties +function set_cluster_property { + if [ -z $2 ]; then + if [ -f "${JIRA_HOME}/cluster.properties" ]; then + sed -i -e "/^${1}/d" "${JIRA_HOME}/cluster.properties" + fi + return + fi + if [ ! -f "${JIRA_HOME}/cluster.properties" ]; then + echo "${1}=${2}" >> "${JIRA_HOME}/cluster.properties" + elif grep "^${1}" "${JIRA_HOME}/cluster.properties"; then + sed -i -e "s#^${1}=.*#${1}=${2}#g" "${JIRA_HOME}/cluster.properties" + else + echo "${1}=${2}" >> "${JIRA_HOME}/cluster.properties" + fi +} + +if [ "${CLUSTERED}" == "true" ]; then + set_cluster_property "jira.node.id" "${JIRA_NODE_ID}" + set_cluster_property "jira.shared.home" "${JIRA_SHARED_HOME}" + set_cluster_property "ehcache.peer.discovery" "${EHCACHE_PEER_DISCOVERY}" + set_cluster_property "ehcache.listener.hostName" "${EHCACHE_LISTENER_HOSTNAME}" + set_cluster_property "ehcache.listener.port" "${EHCACHE_LISTENER_PORT}" + set_cluster_property "ehcache.listener.socketTimeoutMillis" "${EHCACHE_LISTENER_PORT}" + set_cluster_property "ehcache.multicast.address" "${EHCACHE_MULTICAST_ADDRESS}" + set_cluster_property "ehcache.multicast.port" "${EHCACHE_MULTICAST_PORT}" + set_cluster_property "ehcache.multicast.timeToLive" "${EHCACHE_MULTICAST_TIMETOLIVE}" + set_cluster_property "ehcache.multicast.hostName" "${EHCACHE_MULTICAST_HOSTNAME}" +fi + + +# Start Jira as the correct user +if [ "${UID}" -eq 0 ]; then + echo "User is currently root. Will change directory ownership to ${RUN_USER}:${RUN_GROUP}, then downgrade permission to ${RUN_USER}" + PERMISSIONS_SIGNATURE=$(stat -c "%u:%U:%a" "${JIRA_HOME}") + EXPECTED_PERMISSIONS=$(id -u ${RUN_USER}):${RUN_USER}:700 + if [ "${PERMISSIONS_SIGNATURE}" != "${EXPECTED_PERMISSIONS}" ]; then + chmod -R 700 "${JIRA_HOME}" && + chown -R "${RUN_USER}:${RUN_GROUP}" "${JIRA_HOME}" + fi + # Now drop privileges + exec su -s /bin/bash "${RUN_USER}" -c "$JIRA_INSTALL_DIR/bin/start-jira.sh $@" +else + exec "$JIRA_INSTALL_DIR/bin/start-jira.sh" "$@" +fi diff --git a/linux/ecosystem/atlassian/jira/9/9.12.12/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.12.12/kaniko-build.py new file mode 100644 index 000000000..e693b5c17 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.12.12/kaniko-build.py @@ -0,0 +1,196 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections import defaultdict +from concurrent.futures import ThreadPoolExecutor, as_completed +from dotenv import load_dotenv +import logging +import sys + +# Script version +SCRIPT_VERSION = "1.0.1.0" + +# ASCII art for EpicMorg +ASCII_ART = r""" ++=================================================+ +| ____| _) \ | | +| __| __ \ | __| |\/ | _ \ __| _` | | +| | | | | ( | | ( | | ( | | +|_____| .__/ _| \___| _| _| \___/ _| \__, | | +| | / _| _) | |___/ | +| ' / _` | __ \ | | / _ \ | +| . \ ( | | | | < ( | | +|_|\_\ \__,_| _| _| _| _|\_\ \___/ | +|\ \ / | +| \ \ \ / __| _` | __ \ __ \ _ \ __|| +| \ \ \ / | ( | | | | | __/ | | +| \_/\_/ _| \__,_| .__/ .__/ \___| _| | +| _| _| | ++=================================================+ +""" + +# Load environment variables from .env file +load_dotenv() + +def setup_logging(): + logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + +def parse_args(): + parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) + parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') + parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') + parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') + parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') + parser.add_argument('--version', '-v', action='store_true', help='Show script version') + parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') + return parser.parse_args() + +def load_compose_file(file_path): + with open(file_path, 'r') as file: + return yaml.safe_load(file) + +def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): + kaniko_command = [ + 'docker', 'run', + '--rm', + '-t', + '-v', f'{os.path.abspath(build_context)}:/workspace', + ] + + # Add Docker config mounts for both read-only access + kaniko_command.extend([ + '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon + '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode + ]) + + kaniko_command.extend([ + kaniko_image, + '--context', '/workspace', + '--dockerfile', f'/workspace/{dockerfile}', + '--compressed-caching', + '--single-snapshot', + '--cleanup' + ]) + + if deploy: + kaniko_command.extend([ + '--destination', image_name + ]) + elif dry: + kaniko_command.extend([ + '--no-push' + ]) + else: + kaniko_command.extend([ + '--no-push' + ]) + + # Add build arguments if they exist + for arg_name, arg_value in build_args.items(): + kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) + + logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") + + process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + + # Stream output in real-time + for line in process.stdout: + logging.info(line.strip()) + + process.wait() + + if process.returncode == 0: + logging.info(f"Successfully built {service_name}") + else: + for line in process.stderr: + logging.error(line.strip()) + logging.error(f"Error building {service_name}") + raise Exception(f"Failed to build {service_name}") + +def show_help(): + print(ASCII_ART) + print("EpicMorg: Kaniko-Compose Wrapper\n") + print("Arguments:") + print("--compose-file Path to docker-compose.yml file") + print("--kaniko-image Kaniko executor image") + print("--push, --deploy, -d, -p Deploy the built images to the registry") + print("--dry-run, --dry Dry run: build images without pushing and with cleanup") + print("--version, -v Show script version") + print("--help, -h Show this help message and exit") + +def show_version(): + print(ASCII_ART) + print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") + +def main(): + setup_logging() + + args = parse_args() + + # Show help and exit if --help is provided + if args.help: + show_help() + return + + # Show version and exit if --version or no relevant arguments are provided + if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): + show_version() + return + + compose_file = args.compose_file + kaniko_image = args.kaniko_image + deploy = args.push + dry = args.dry_run + + if not os.path.exists(compose_file): + logging.error(f"{compose_file} not found") + return + + compose_data = load_compose_file(compose_file) + + services = compose_data.get('services', {}) + image_names = defaultdict(int) + + for service_name, service_data in services.items(): + image_name = service_data.get('image') + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + image_names[image_name] += 1 + + for image_name, count in image_names.items(): + if count > 1: + logging.error(f"Error: Image name {image_name} is used {count} times.") + return + + try: + with ThreadPoolExecutor() as executor: + futures = [] + for service_name, service_data in services.items(): + build_data = service_data.get('build', {}) + build_context = build_data.get('context', '.') + dockerfile = build_data.get('dockerfile', 'Dockerfile') + image_name = service_data.get('image') + build_args = build_data.get('args', {}) + + # Substitute environment variables with their values if they exist + build_args = {key: os.getenv(key, value) for key, value in build_args.items()} + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) + + for future in as_completed(futures): + future.result() + except Exception as exc: + logging.error(f"Build failed: {exc}") + sys.exit(1) + +if __name__ == '__main__': + main() diff --git a/linux/ecosystem/atlassian/jira/9/9.12.12/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.12.12/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.12.12/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.12.2/.env b/linux/ecosystem/atlassian/jira/9/9.12.2/.env deleted file mode 100644 index ba7f96020..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.12.2/.env +++ /dev/null @@ -1,2 +0,0 @@ -RELEASE=9.12.2 -DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz \ No newline at end of file diff --git a/linux/ecosystem/atlassian/jira/9/9.12.2/Dockerfile b/linux/ecosystem/atlassian/jira/9/9.12.2/Dockerfile index d3d23294c..fc5e8155b 100644 --- a/linux/ecosystem/atlassian/jira/9/9.12.2/Dockerfile +++ b/linux/ecosystem/atlassian/jira/9/9.12.2/Dockerfile @@ -6,8 +6,8 @@ ARG DEBIAN_FRONTEND=noninteractive # ARGuments ################################################################## -ARG RELEASE -ARG DOWNLOAD_URL +ARG RELEASE=9.12.2 +ARG DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz ################################################################## # Setup @@ -29,7 +29,8 @@ EXPOSE 8080 # Installing ################################################################## RUN mkdir -p ${JIRA_INSTALL_DIR} \ - && curl --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ + && wget --random-wait --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36" -P /tmp/ ${DOWNLOAD_URL} \ + && tar -xzf /tmp/atlassian-jira-software-${RELEASE}.tar.gz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ && chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \ && sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ && sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ diff --git a/linux/ecosystem/atlassian/jira/9/9.12.2/Dockerfile.jdk11 b/linux/ecosystem/atlassian/jira/9/9.12.2/Dockerfile.jdk11 index a1c1e41d7..a8a1a7c4b 100644 --- a/linux/ecosystem/atlassian/jira/9/9.12.2/Dockerfile.jdk11 +++ b/linux/ecosystem/atlassian/jira/9/9.12.2/Dockerfile.jdk11 @@ -6,8 +6,8 @@ ARG DEBIAN_FRONTEND=noninteractive # ARGuments ################################################################## -ARG RELEASE -ARG DOWNLOAD_URL +ARG RELEASE=9.12.2 +ARG DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz ################################################################## # Setup @@ -29,7 +29,8 @@ EXPOSE 8080 # Installing ################################################################## RUN mkdir -p ${JIRA_INSTALL_DIR} \ - && curl --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ + && wget --random-wait --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36" -P /tmp/ ${DOWNLOAD_URL} \ + && tar -xzf /tmp/atlassian-jira-software-${RELEASE}.tar.gz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ && chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \ && sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ && sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ diff --git a/linux/ecosystem/atlassian/jira/9/9.12.2/Dockerfile.jdk17 b/linux/ecosystem/atlassian/jira/9/9.12.2/Dockerfile.jdk17 index fdd79def6..1e624719b 100644 --- a/linux/ecosystem/atlassian/jira/9/9.12.2/Dockerfile.jdk17 +++ b/linux/ecosystem/atlassian/jira/9/9.12.2/Dockerfile.jdk17 @@ -6,8 +6,8 @@ ARG DEBIAN_FRONTEND=noninteractive # ARGuments ################################################################## -ARG RELEASE -ARG DOWNLOAD_URL +ARG RELEASE=9.12.2 +ARG DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz ################################################################## # Setup @@ -29,7 +29,8 @@ EXPOSE 8080 # Installing ################################################################## RUN mkdir -p ${JIRA_INSTALL_DIR} \ - && curl --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ + && wget --random-wait --retry-connrefused --waitretry=5 --read-timeout=20 --timeout=15 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36" -P /tmp/ ${DOWNLOAD_URL} \ + && tar -xzf /tmp/atlassian-jira-software-${RELEASE}.tar.gz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ && chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \ && sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ && sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ diff --git a/linux/ecosystem/atlassian/jira/9/9.12.2/docker-compose.yml b/linux/ecosystem/atlassian/jira/9/9.12.2/docker-compose.yml index 32c492ee6..bbd71d7b7 100644 --- a/linux/ecosystem/atlassian/jira/9/9.12.2/docker-compose.yml +++ b/linux/ecosystem/atlassian/jira/9/9.12.2/docker-compose.yml @@ -1,25 +1,16 @@ #version: '3' services: app: - image: "epicmorg/jira:${RELEASE}" + image: "epicmorg/jira:9.12.2" build: context: . - args: - RELEASE: ${RELEASE} - DOWNLOAD_URL: ${DOWNLOAD_URL} app-jdk11: - image: "epicmorg/jira:${RELEASE}-jdk11" + image: "epicmorg/jira:9.12.2-jdk11" build: context: . dockerfile: Dockerfile.jdk11 - args: - RELEASE: ${RELEASE} - DOWNLOAD_URL: ${DOWNLOAD_URL} app-jdk17: - image: "epicmorg/jira:${RELEASE}-jdk17" + image: "epicmorg/jira:9.12.2-jdk17" build: context: . dockerfile: Dockerfile.jdk17 - args: - RELEASE: ${RELEASE} - DOWNLOAD_URL: ${DOWNLOAD_URL} diff --git a/linux/ecosystem/atlassian/jira/9/9.14.1/Dockerfile b/linux/ecosystem/atlassian/jira/9/9.14.1/Dockerfile new file mode 100644 index 000000000..3da7edb02 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.14.1/Dockerfile @@ -0,0 +1,53 @@ +FROM epicmorg/debian:bookworm-jdk8 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## + +ARG RELEASE=9.14.1 +ARG DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/JSERVERM/Important+directories+and+files +ENV JIRA_HOME /var/atlassian/application-data/jira +ENV JIRA_INSTALL_DIR /opt/atlassian/jira + +VOLUME ["${JIRA_HOME}"] +WORKDIR $JIRA_HOME + +# Expose HTTP port +EXPOSE 8080 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${JIRA_INSTALL_DIR} \ + && wget --random-wait --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36" -P /tmp/ ${DOWNLOAD_URL} \ + && tar -xzf /tmp/atlassian-jira-software-${RELEASE}.tar.gz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \ + && sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/grep "java version"/grep -E "(openjdk|java) version"/g' ${JIRA_INSTALL_DIR}/bin/check-java.sh \ + && sed -i -e 's/port="8080"/port="8080" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${JIRA_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb && \ + rm -rfv /tmp/* + + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/jira/9/9.14.1/Dockerfile.jdk11 b/linux/ecosystem/atlassian/jira/9/9.14.1/Dockerfile.jdk11 new file mode 100644 index 000000000..6775c8017 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.14.1/Dockerfile.jdk11 @@ -0,0 +1,52 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## + +ARG RELEASE=9.14.1 +ARG DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/JSERVERM/Important+directories+and+files +ENV JIRA_HOME /var/atlassian/application-data/jira +ENV JIRA_INSTALL_DIR /opt/atlassian/jira + +VOLUME ["${JIRA_HOME}"] +WORKDIR $JIRA_HOME + +# Expose HTTP port +EXPOSE 8080 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${JIRA_INSTALL_DIR} \ + && wget --random-wait --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36" -P /tmp/ ${DOWNLOAD_URL} \ + && tar -xzf /tmp/atlassian-jira-software-${RELEASE}.tar.gz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \ + && sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/grep "java version"/grep -E "(openjdk|java) version"/g' ${JIRA_INSTALL_DIR}/bin/check-java.sh \ + && sed -i -e 's/port="8080"/port="8080" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${JIRA_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb && \ + rm -rfv /tmp/* + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/jira/9/9.14.1/Dockerfile.jdk17 b/linux/ecosystem/atlassian/jira/9/9.14.1/Dockerfile.jdk17 new file mode 100644 index 000000000..f4a52bbca --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.14.1/Dockerfile.jdk17 @@ -0,0 +1,52 @@ +FROM epicmorg/debian:bookworm-jdk17 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## + +ARG RELEASE=9.14.1 +ARG DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/JSERVERM/Important+directories+and+files +ENV JIRA_HOME /var/atlassian/application-data/jira +ENV JIRA_INSTALL_DIR /opt/atlassian/jira + +VOLUME ["${JIRA_HOME}"] +WORKDIR $JIRA_HOME + +# Expose HTTP port +EXPOSE 8080 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${JIRA_INSTALL_DIR} \ + && wget --random-wait --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36" -P /tmp/ ${DOWNLOAD_URL} \ + && tar -xzf /tmp/atlassian-jira-software-${RELEASE}.tar.gz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \ + && sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/grep "java version"/grep -E "(openjdk|java) version"/g' ${JIRA_INSTALL_DIR}/bin/check-java.sh \ + && sed -i -e 's/port="8080"/port="8080" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${JIRA_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb && \ + rm -rfv /tmp/* + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/jira/9/9.14.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.14.1/Makefile new file mode 100644 index 000000000..3383c9699 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.14.1/Makefile @@ -0,0 +1,50 @@ +PIP_BREAK_SYSTEM_PACKAGES=1 + +all: app + +app: + make build + make deploy + make clean + +build: + make pip + python3 kaniko-build.py --version + +dry: + make dry-run + +test: + make dry-run + +dry-run: + python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + +pip: + rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.7/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.8/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.12/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.13/EXTERNALLY-MANAGED + pip3 install -r requirements.txt + pip install -r requirements.txt + +build-compose: + docker-compose build --compress --parallel --progress plain + +deploy: + make pip + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + +deploy-compose: + docker-compose push + +clean: + docker container prune -f + docker image prune -f + docker network prune -f + docker volume prune -f + docker system prune -af diff --git a/linux/ecosystem/atlassian/jira/9/9.14.1/docker-compose.yml b/linux/ecosystem/atlassian/jira/9/9.14.1/docker-compose.yml new file mode 100644 index 000000000..caa448ba8 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.14.1/docker-compose.yml @@ -0,0 +1,16 @@ +#version: '3' +services: + app: + image: "epicmorg/jira:9.14.1" + build: + context: . + app-jdk11: + image: "epicmorg/jira:9.14.1-jdk11" + build: + context: . + dockerfile: Dockerfile.jdk11 + app-jdk17: + image: "epicmorg/jira:9.14.1-jdk17" + build: + context: . + dockerfile: Dockerfile.jdk17 diff --git a/linux/ecosystem/atlassian/jira/9/9.14.1/entrypoint.sh b/linux/ecosystem/atlassian/jira/9/9.14.1/entrypoint.sh new file mode 100755 index 000000000..50ee4ecd1 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.14.1/entrypoint.sh @@ -0,0 +1,89 @@ +#!/bin/bash +set -euo pipefail + +export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") +export JRE_HOME="$JAVA_HOME/jre" +export JAVA_BINARY="$JRE_HOME/bin/java" +export JAVA_VERSION=$("$JAVA_BINARY" -version 2>&1 | awk -F '"' '/version/ {print $2}') + +# Setup Catalina Opts +: ${CATALINA_CONNECTOR_PROXYNAME:=} +: ${CATALINA_CONNECTOR_PROXYPORT:=} +: ${CATALINA_CONNECTOR_SCHEME:=http} +: ${CATALINA_CONNECTOR_SECURE:=false} + +: ${CATALINA_OPTS:=} + +: ${JAVA_OPTS:=} + +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyName=${CATALINA_CONNECTOR_PROXYNAME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyPort=${CATALINA_CONNECTOR_PROXYPORT}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorScheme=${CATALINA_CONNECTOR_SCHEME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorSecure=${CATALINA_CONNECTOR_SECURE}" + +export JAVA_OPTS="${JAVA_OPTS} ${CATALINA_OPTS}" + +# Setup Data Center configuration +if [ ! -f "/etc/container_id" ]; then + uuidgen > /etc/container_id +fi +CONTAINER_ID=$(cat /etc/container_id) +CONTAINER_SHORT_ID=${CONTAINER_ID::8} + +: ${CLUSTERED:=false} +: ${JIRA_NODE_ID:=jira_node_${CONTAINER_SHORT_ID}} +: ${JIRA_SHARED_HOME:=${JIRA_HOME}/shared} +: ${EHCACHE_PEER_DISCOVERY:=} +: ${EHCACHE_LISTENER_HOSTNAME:=} +: ${EHCACHE_LISTENER_PORT:=} +: ${EHCACHE_LISTENER_SOCKETTIMEOUTMILLIS:=} +: ${EHCACHE_MULTICAST_ADDRESS:=} +: ${EHCACHE_MULTICAST_PORT:=} +: ${EHCACHE_MULTICAST_TIMETOLIVE:=} +: ${EHCACHE_MULTICAST_HOSTNAME:=} + +# Cleanly set/unset values in cluster.properties +function set_cluster_property { + if [ -z $2 ]; then + if [ -f "${JIRA_HOME}/cluster.properties" ]; then + sed -i -e "/^${1}/d" "${JIRA_HOME}/cluster.properties" + fi + return + fi + if [ ! -f "${JIRA_HOME}/cluster.properties" ]; then + echo "${1}=${2}" >> "${JIRA_HOME}/cluster.properties" + elif grep "^${1}" "${JIRA_HOME}/cluster.properties"; then + sed -i -e "s#^${1}=.*#${1}=${2}#g" "${JIRA_HOME}/cluster.properties" + else + echo "${1}=${2}" >> "${JIRA_HOME}/cluster.properties" + fi +} + +if [ "${CLUSTERED}" == "true" ]; then + set_cluster_property "jira.node.id" "${JIRA_NODE_ID}" + set_cluster_property "jira.shared.home" "${JIRA_SHARED_HOME}" + set_cluster_property "ehcache.peer.discovery" "${EHCACHE_PEER_DISCOVERY}" + set_cluster_property "ehcache.listener.hostName" "${EHCACHE_LISTENER_HOSTNAME}" + set_cluster_property "ehcache.listener.port" "${EHCACHE_LISTENER_PORT}" + set_cluster_property "ehcache.listener.socketTimeoutMillis" "${EHCACHE_LISTENER_PORT}" + set_cluster_property "ehcache.multicast.address" "${EHCACHE_MULTICAST_ADDRESS}" + set_cluster_property "ehcache.multicast.port" "${EHCACHE_MULTICAST_PORT}" + set_cluster_property "ehcache.multicast.timeToLive" "${EHCACHE_MULTICAST_TIMETOLIVE}" + set_cluster_property "ehcache.multicast.hostName" "${EHCACHE_MULTICAST_HOSTNAME}" +fi + + +# Start Jira as the correct user +if [ "${UID}" -eq 0 ]; then + echo "User is currently root. Will change directory ownership to ${RUN_USER}:${RUN_GROUP}, then downgrade permission to ${RUN_USER}" + PERMISSIONS_SIGNATURE=$(stat -c "%u:%U:%a" "${JIRA_HOME}") + EXPECTED_PERMISSIONS=$(id -u ${RUN_USER}):${RUN_USER}:700 + if [ "${PERMISSIONS_SIGNATURE}" != "${EXPECTED_PERMISSIONS}" ]; then + chmod -R 700 "${JIRA_HOME}" && + chown -R "${RUN_USER}:${RUN_GROUP}" "${JIRA_HOME}" + fi + # Now drop privileges + exec su -s /bin/bash "${RUN_USER}" -c "$JIRA_INSTALL_DIR/bin/start-jira.sh $@" +else + exec "$JIRA_INSTALL_DIR/bin/start-jira.sh" "$@" +fi diff --git a/linux/ecosystem/atlassian/jira/9/9.14.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.14.1/kaniko-build.py new file mode 100644 index 000000000..e693b5c17 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.14.1/kaniko-build.py @@ -0,0 +1,196 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections import defaultdict +from concurrent.futures import ThreadPoolExecutor, as_completed +from dotenv import load_dotenv +import logging +import sys + +# Script version +SCRIPT_VERSION = "1.0.1.0" + +# ASCII art for EpicMorg +ASCII_ART = r""" ++=================================================+ +| ____| _) \ | | +| __| __ \ | __| |\/ | _ \ __| _` | | +| | | | | ( | | ( | | ( | | +|_____| .__/ _| \___| _| _| \___/ _| \__, | | +| | / _| _) | |___/ | +| ' / _` | __ \ | | / _ \ | +| . \ ( | | | | < ( | | +|_|\_\ \__,_| _| _| _| _|\_\ \___/ | +|\ \ / | +| \ \ \ / __| _` | __ \ __ \ _ \ __|| +| \ \ \ / | ( | | | | | __/ | | +| \_/\_/ _| \__,_| .__/ .__/ \___| _| | +| _| _| | ++=================================================+ +""" + +# Load environment variables from .env file +load_dotenv() + +def setup_logging(): + logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + +def parse_args(): + parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) + parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') + parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') + parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') + parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') + parser.add_argument('--version', '-v', action='store_true', help='Show script version') + parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') + return parser.parse_args() + +def load_compose_file(file_path): + with open(file_path, 'r') as file: + return yaml.safe_load(file) + +def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): + kaniko_command = [ + 'docker', 'run', + '--rm', + '-t', + '-v', f'{os.path.abspath(build_context)}:/workspace', + ] + + # Add Docker config mounts for both read-only access + kaniko_command.extend([ + '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon + '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode + ]) + + kaniko_command.extend([ + kaniko_image, + '--context', '/workspace', + '--dockerfile', f'/workspace/{dockerfile}', + '--compressed-caching', + '--single-snapshot', + '--cleanup' + ]) + + if deploy: + kaniko_command.extend([ + '--destination', image_name + ]) + elif dry: + kaniko_command.extend([ + '--no-push' + ]) + else: + kaniko_command.extend([ + '--no-push' + ]) + + # Add build arguments if they exist + for arg_name, arg_value in build_args.items(): + kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) + + logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") + + process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + + # Stream output in real-time + for line in process.stdout: + logging.info(line.strip()) + + process.wait() + + if process.returncode == 0: + logging.info(f"Successfully built {service_name}") + else: + for line in process.stderr: + logging.error(line.strip()) + logging.error(f"Error building {service_name}") + raise Exception(f"Failed to build {service_name}") + +def show_help(): + print(ASCII_ART) + print("EpicMorg: Kaniko-Compose Wrapper\n") + print("Arguments:") + print("--compose-file Path to docker-compose.yml file") + print("--kaniko-image Kaniko executor image") + print("--push, --deploy, -d, -p Deploy the built images to the registry") + print("--dry-run, --dry Dry run: build images without pushing and with cleanup") + print("--version, -v Show script version") + print("--help, -h Show this help message and exit") + +def show_version(): + print(ASCII_ART) + print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") + +def main(): + setup_logging() + + args = parse_args() + + # Show help and exit if --help is provided + if args.help: + show_help() + return + + # Show version and exit if --version or no relevant arguments are provided + if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): + show_version() + return + + compose_file = args.compose_file + kaniko_image = args.kaniko_image + deploy = args.push + dry = args.dry_run + + if not os.path.exists(compose_file): + logging.error(f"{compose_file} not found") + return + + compose_data = load_compose_file(compose_file) + + services = compose_data.get('services', {}) + image_names = defaultdict(int) + + for service_name, service_data in services.items(): + image_name = service_data.get('image') + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + image_names[image_name] += 1 + + for image_name, count in image_names.items(): + if count > 1: + logging.error(f"Error: Image name {image_name} is used {count} times.") + return + + try: + with ThreadPoolExecutor() as executor: + futures = [] + for service_name, service_data in services.items(): + build_data = service_data.get('build', {}) + build_context = build_data.get('context', '.') + dockerfile = build_data.get('dockerfile', 'Dockerfile') + image_name = service_data.get('image') + build_args = build_data.get('args', {}) + + # Substitute environment variables with their values if they exist + build_args = {key: os.getenv(key, value) for key, value in build_args.items()} + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) + + for future in as_completed(futures): + future.result() + except Exception as exc: + logging.error(f"Build failed: {exc}") + sys.exit(1) + +if __name__ == '__main__': + main() diff --git a/linux/ecosystem/atlassian/jira/9/9.14.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.14.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.14.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.16.1/Dockerfile b/linux/ecosystem/atlassian/jira/9/9.16.1/Dockerfile new file mode 100644 index 000000000..815204e4d --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.16.1/Dockerfile @@ -0,0 +1,53 @@ +FROM epicmorg/debian:bookworm-jdk8 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## + +ARG RELEASE=9.16.1 +ARG DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/JSERVERM/Important+directories+and+files +ENV JIRA_HOME /var/atlassian/application-data/jira +ENV JIRA_INSTALL_DIR /opt/atlassian/jira + +VOLUME ["${JIRA_HOME}"] +WORKDIR $JIRA_HOME + +# Expose HTTP port +EXPOSE 8080 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${JIRA_INSTALL_DIR} \ + && wget --random-wait --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36" -P /tmp/ ${DOWNLOAD_URL} \ + && tar -xzf /tmp/atlassian-jira-software-${RELEASE}.tar.gz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \ + && sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/grep "java version"/grep -E "(openjdk|java) version"/g' ${JIRA_INSTALL_DIR}/bin/check-java.sh \ + && sed -i -e 's/port="8080"/port="8080" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${JIRA_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb && \ + rm -rfv /tmp/* + + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/jira/9/9.16.1/Dockerfile.jdk11 b/linux/ecosystem/atlassian/jira/9/9.16.1/Dockerfile.jdk11 new file mode 100644 index 000000000..4c75a446d --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.16.1/Dockerfile.jdk11 @@ -0,0 +1,52 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## + +ARG RELEASE=9.16.1 +ARG DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/JSERVERM/Important+directories+and+files +ENV JIRA_HOME /var/atlassian/application-data/jira +ENV JIRA_INSTALL_DIR /opt/atlassian/jira + +VOLUME ["${JIRA_HOME}"] +WORKDIR $JIRA_HOME + +# Expose HTTP port +EXPOSE 8080 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${JIRA_INSTALL_DIR} \ + && wget --random-wait --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36" -P /tmp/ ${DOWNLOAD_URL} \ + && tar -xzf /tmp/atlassian-jira-software-${RELEASE}.tar.gz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \ + && sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/grep "java version"/grep -E "(openjdk|java) version"/g' ${JIRA_INSTALL_DIR}/bin/check-java.sh \ + && sed -i -e 's/port="8080"/port="8080" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${JIRA_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb && \ + rm -rfv /tmp/* + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/jira/9/9.16.1/Dockerfile.jdk17 b/linux/ecosystem/atlassian/jira/9/9.16.1/Dockerfile.jdk17 new file mode 100644 index 000000000..137514a28 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.16.1/Dockerfile.jdk17 @@ -0,0 +1,52 @@ +FROM epicmorg/debian:bookworm-jdk17 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## + +ARG RELEASE=9.16.1 +ARG DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/JSERVERM/Important+directories+and+files +ENV JIRA_HOME /var/atlassian/application-data/jira +ENV JIRA_INSTALL_DIR /opt/atlassian/jira + +VOLUME ["${JIRA_HOME}"] +WORKDIR $JIRA_HOME + +# Expose HTTP port +EXPOSE 8080 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${JIRA_INSTALL_DIR} \ + && wget --random-wait --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36" -P /tmp/ ${DOWNLOAD_URL} \ + && tar -xzf /tmp/atlassian-jira-software-${RELEASE}.tar.gz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \ + && sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/grep "java version"/grep -E "(openjdk|java) version"/g' ${JIRA_INSTALL_DIR}/bin/check-java.sh \ + && sed -i -e 's/port="8080"/port="8080" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${JIRA_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb && \ + rm -rfv /tmp/* + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/jira/9/9.16.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.16.1/Makefile new file mode 100644 index 000000000..3383c9699 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.16.1/Makefile @@ -0,0 +1,50 @@ +PIP_BREAK_SYSTEM_PACKAGES=1 + +all: app + +app: + make build + make deploy + make clean + +build: + make pip + python3 kaniko-build.py --version + +dry: + make dry-run + +test: + make dry-run + +dry-run: + python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + +pip: + rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.7/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.8/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.12/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.13/EXTERNALLY-MANAGED + pip3 install -r requirements.txt + pip install -r requirements.txt + +build-compose: + docker-compose build --compress --parallel --progress plain + +deploy: + make pip + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + +deploy-compose: + docker-compose push + +clean: + docker container prune -f + docker image prune -f + docker network prune -f + docker volume prune -f + docker system prune -af diff --git a/linux/ecosystem/atlassian/jira/9/9.16.1/docker-compose.yml b/linux/ecosystem/atlassian/jira/9/9.16.1/docker-compose.yml new file mode 100644 index 000000000..312dfee53 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.16.1/docker-compose.yml @@ -0,0 +1,16 @@ +#version: '3' +services: + app: + image: "epicmorg/jira:9.16.1" + build: + context: . + app-jdk11: + image: "epicmorg/jira:9.16.1-jdk11" + build: + context: . + dockerfile: Dockerfile.jdk11 + app-jdk17: + image: "epicmorg/jira:9.16.1-jdk17" + build: + context: . + dockerfile: Dockerfile.jdk17 diff --git a/linux/ecosystem/atlassian/jira/9/9.16.1/entrypoint.sh b/linux/ecosystem/atlassian/jira/9/9.16.1/entrypoint.sh new file mode 100755 index 000000000..50ee4ecd1 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.16.1/entrypoint.sh @@ -0,0 +1,89 @@ +#!/bin/bash +set -euo pipefail + +export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") +export JRE_HOME="$JAVA_HOME/jre" +export JAVA_BINARY="$JRE_HOME/bin/java" +export JAVA_VERSION=$("$JAVA_BINARY" -version 2>&1 | awk -F '"' '/version/ {print $2}') + +# Setup Catalina Opts +: ${CATALINA_CONNECTOR_PROXYNAME:=} +: ${CATALINA_CONNECTOR_PROXYPORT:=} +: ${CATALINA_CONNECTOR_SCHEME:=http} +: ${CATALINA_CONNECTOR_SECURE:=false} + +: ${CATALINA_OPTS:=} + +: ${JAVA_OPTS:=} + +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyName=${CATALINA_CONNECTOR_PROXYNAME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyPort=${CATALINA_CONNECTOR_PROXYPORT}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorScheme=${CATALINA_CONNECTOR_SCHEME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorSecure=${CATALINA_CONNECTOR_SECURE}" + +export JAVA_OPTS="${JAVA_OPTS} ${CATALINA_OPTS}" + +# Setup Data Center configuration +if [ ! -f "/etc/container_id" ]; then + uuidgen > /etc/container_id +fi +CONTAINER_ID=$(cat /etc/container_id) +CONTAINER_SHORT_ID=${CONTAINER_ID::8} + +: ${CLUSTERED:=false} +: ${JIRA_NODE_ID:=jira_node_${CONTAINER_SHORT_ID}} +: ${JIRA_SHARED_HOME:=${JIRA_HOME}/shared} +: ${EHCACHE_PEER_DISCOVERY:=} +: ${EHCACHE_LISTENER_HOSTNAME:=} +: ${EHCACHE_LISTENER_PORT:=} +: ${EHCACHE_LISTENER_SOCKETTIMEOUTMILLIS:=} +: ${EHCACHE_MULTICAST_ADDRESS:=} +: ${EHCACHE_MULTICAST_PORT:=} +: ${EHCACHE_MULTICAST_TIMETOLIVE:=} +: ${EHCACHE_MULTICAST_HOSTNAME:=} + +# Cleanly set/unset values in cluster.properties +function set_cluster_property { + if [ -z $2 ]; then + if [ -f "${JIRA_HOME}/cluster.properties" ]; then + sed -i -e "/^${1}/d" "${JIRA_HOME}/cluster.properties" + fi + return + fi + if [ ! -f "${JIRA_HOME}/cluster.properties" ]; then + echo "${1}=${2}" >> "${JIRA_HOME}/cluster.properties" + elif grep "^${1}" "${JIRA_HOME}/cluster.properties"; then + sed -i -e "s#^${1}=.*#${1}=${2}#g" "${JIRA_HOME}/cluster.properties" + else + echo "${1}=${2}" >> "${JIRA_HOME}/cluster.properties" + fi +} + +if [ "${CLUSTERED}" == "true" ]; then + set_cluster_property "jira.node.id" "${JIRA_NODE_ID}" + set_cluster_property "jira.shared.home" "${JIRA_SHARED_HOME}" + set_cluster_property "ehcache.peer.discovery" "${EHCACHE_PEER_DISCOVERY}" + set_cluster_property "ehcache.listener.hostName" "${EHCACHE_LISTENER_HOSTNAME}" + set_cluster_property "ehcache.listener.port" "${EHCACHE_LISTENER_PORT}" + set_cluster_property "ehcache.listener.socketTimeoutMillis" "${EHCACHE_LISTENER_PORT}" + set_cluster_property "ehcache.multicast.address" "${EHCACHE_MULTICAST_ADDRESS}" + set_cluster_property "ehcache.multicast.port" "${EHCACHE_MULTICAST_PORT}" + set_cluster_property "ehcache.multicast.timeToLive" "${EHCACHE_MULTICAST_TIMETOLIVE}" + set_cluster_property "ehcache.multicast.hostName" "${EHCACHE_MULTICAST_HOSTNAME}" +fi + + +# Start Jira as the correct user +if [ "${UID}" -eq 0 ]; then + echo "User is currently root. Will change directory ownership to ${RUN_USER}:${RUN_GROUP}, then downgrade permission to ${RUN_USER}" + PERMISSIONS_SIGNATURE=$(stat -c "%u:%U:%a" "${JIRA_HOME}") + EXPECTED_PERMISSIONS=$(id -u ${RUN_USER}):${RUN_USER}:700 + if [ "${PERMISSIONS_SIGNATURE}" != "${EXPECTED_PERMISSIONS}" ]; then + chmod -R 700 "${JIRA_HOME}" && + chown -R "${RUN_USER}:${RUN_GROUP}" "${JIRA_HOME}" + fi + # Now drop privileges + exec su -s /bin/bash "${RUN_USER}" -c "$JIRA_INSTALL_DIR/bin/start-jira.sh $@" +else + exec "$JIRA_INSTALL_DIR/bin/start-jira.sh" "$@" +fi diff --git a/linux/ecosystem/atlassian/jira/9/9.16.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.16.1/kaniko-build.py new file mode 100644 index 000000000..e693b5c17 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.16.1/kaniko-build.py @@ -0,0 +1,196 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections import defaultdict +from concurrent.futures import ThreadPoolExecutor, as_completed +from dotenv import load_dotenv +import logging +import sys + +# Script version +SCRIPT_VERSION = "1.0.1.0" + +# ASCII art for EpicMorg +ASCII_ART = r""" ++=================================================+ +| ____| _) \ | | +| __| __ \ | __| |\/ | _ \ __| _` | | +| | | | | ( | | ( | | ( | | +|_____| .__/ _| \___| _| _| \___/ _| \__, | | +| | / _| _) | |___/ | +| ' / _` | __ \ | | / _ \ | +| . \ ( | | | | < ( | | +|_|\_\ \__,_| _| _| _| _|\_\ \___/ | +|\ \ / | +| \ \ \ / __| _` | __ \ __ \ _ \ __|| +| \ \ \ / | ( | | | | | __/ | | +| \_/\_/ _| \__,_| .__/ .__/ \___| _| | +| _| _| | ++=================================================+ +""" + +# Load environment variables from .env file +load_dotenv() + +def setup_logging(): + logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + +def parse_args(): + parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) + parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') + parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') + parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') + parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') + parser.add_argument('--version', '-v', action='store_true', help='Show script version') + parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') + return parser.parse_args() + +def load_compose_file(file_path): + with open(file_path, 'r') as file: + return yaml.safe_load(file) + +def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): + kaniko_command = [ + 'docker', 'run', + '--rm', + '-t', + '-v', f'{os.path.abspath(build_context)}:/workspace', + ] + + # Add Docker config mounts for both read-only access + kaniko_command.extend([ + '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon + '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode + ]) + + kaniko_command.extend([ + kaniko_image, + '--context', '/workspace', + '--dockerfile', f'/workspace/{dockerfile}', + '--compressed-caching', + '--single-snapshot', + '--cleanup' + ]) + + if deploy: + kaniko_command.extend([ + '--destination', image_name + ]) + elif dry: + kaniko_command.extend([ + '--no-push' + ]) + else: + kaniko_command.extend([ + '--no-push' + ]) + + # Add build arguments if they exist + for arg_name, arg_value in build_args.items(): + kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) + + logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") + + process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + + # Stream output in real-time + for line in process.stdout: + logging.info(line.strip()) + + process.wait() + + if process.returncode == 0: + logging.info(f"Successfully built {service_name}") + else: + for line in process.stderr: + logging.error(line.strip()) + logging.error(f"Error building {service_name}") + raise Exception(f"Failed to build {service_name}") + +def show_help(): + print(ASCII_ART) + print("EpicMorg: Kaniko-Compose Wrapper\n") + print("Arguments:") + print("--compose-file Path to docker-compose.yml file") + print("--kaniko-image Kaniko executor image") + print("--push, --deploy, -d, -p Deploy the built images to the registry") + print("--dry-run, --dry Dry run: build images without pushing and with cleanup") + print("--version, -v Show script version") + print("--help, -h Show this help message and exit") + +def show_version(): + print(ASCII_ART) + print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") + +def main(): + setup_logging() + + args = parse_args() + + # Show help and exit if --help is provided + if args.help: + show_help() + return + + # Show version and exit if --version or no relevant arguments are provided + if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): + show_version() + return + + compose_file = args.compose_file + kaniko_image = args.kaniko_image + deploy = args.push + dry = args.dry_run + + if not os.path.exists(compose_file): + logging.error(f"{compose_file} not found") + return + + compose_data = load_compose_file(compose_file) + + services = compose_data.get('services', {}) + image_names = defaultdict(int) + + for service_name, service_data in services.items(): + image_name = service_data.get('image') + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + image_names[image_name] += 1 + + for image_name, count in image_names.items(): + if count > 1: + logging.error(f"Error: Image name {image_name} is used {count} times.") + return + + try: + with ThreadPoolExecutor() as executor: + futures = [] + for service_name, service_data in services.items(): + build_data = service_data.get('build', {}) + build_context = build_data.get('context', '.') + dockerfile = build_data.get('dockerfile', 'Dockerfile') + image_name = service_data.get('image') + build_args = build_data.get('args', {}) + + # Substitute environment variables with their values if they exist + build_args = {key: os.getenv(key, value) for key, value in build_args.items()} + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) + + for future in as_completed(futures): + future.result() + except Exception as exc: + logging.error(f"Build failed: {exc}") + sys.exit(1) + +if __name__ == '__main__': + main() diff --git a/linux/ecosystem/atlassian/jira/9/9.16.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.16.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.16.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/atlassian/jira/9/9.17.1/Dockerfile b/linux/ecosystem/atlassian/jira/9/9.17.1/Dockerfile new file mode 100644 index 000000000..f24640223 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.17.1/Dockerfile @@ -0,0 +1,53 @@ +FROM epicmorg/debian:bookworm-jdk8 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## + +ARG RELEASE=9.17.1 +ARG DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/JSERVERM/Important+directories+and+files +ENV JIRA_HOME /var/atlassian/application-data/jira +ENV JIRA_INSTALL_DIR /opt/atlassian/jira + +VOLUME ["${JIRA_HOME}"] +WORKDIR $JIRA_HOME + +# Expose HTTP port +EXPOSE 8080 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${JIRA_INSTALL_DIR} \ + && wget --random-wait --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36" -P /tmp/ ${DOWNLOAD_URL} \ + && tar -xzf /tmp/atlassian-jira-software-${RELEASE}.tar.gz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \ + && sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/grep "java version"/grep -E "(openjdk|java) version"/g' ${JIRA_INSTALL_DIR}/bin/check-java.sh \ + && sed -i -e 's/port="8080"/port="8080" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${JIRA_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb && \ + rm -rfv /tmp/* + + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/jira/9/9.17.1/Dockerfile.jdk11 b/linux/ecosystem/atlassian/jira/9/9.17.1/Dockerfile.jdk11 new file mode 100644 index 000000000..55d146cf5 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.17.1/Dockerfile.jdk11 @@ -0,0 +1,52 @@ +FROM epicmorg/debian:bookworm-jdk11 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## + +ARG RELEASE=9.17.1 +ARG DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/JSERVERM/Important+directories+and+files +ENV JIRA_HOME /var/atlassian/application-data/jira +ENV JIRA_INSTALL_DIR /opt/atlassian/jira + +VOLUME ["${JIRA_HOME}"] +WORKDIR $JIRA_HOME + +# Expose HTTP port +EXPOSE 8080 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${JIRA_INSTALL_DIR} \ + && wget --random-wait --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36" -P /tmp/ ${DOWNLOAD_URL} \ + && tar -xzf /tmp/atlassian-jira-software-${RELEASE}.tar.gz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \ + && sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/grep "java version"/grep -E "(openjdk|java) version"/g' ${JIRA_INSTALL_DIR}/bin/check-java.sh \ + && sed -i -e 's/port="8080"/port="8080" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${JIRA_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb && \ + rm -rfv /tmp/* + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/jira/9/9.17.1/Dockerfile.jdk17 b/linux/ecosystem/atlassian/jira/9/9.17.1/Dockerfile.jdk17 new file mode 100644 index 000000000..6fbd4c71d --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.17.1/Dockerfile.jdk17 @@ -0,0 +1,52 @@ +FROM epicmorg/debian:bookworm-jdk17 +LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org" +ARG DEBIAN_FRONTEND=noninteractive + +################################################################## +# ARGuments +################################################################## + +ARG RELEASE=9.17.1 +ARG DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz + +################################################################## +# Setup +################################################################## +ENV RUN_USER daemon +ENV RUN_GROUP daemon + +# https://confluence.atlassian.com/display/JSERVERM/Important+directories+and+files +ENV JIRA_HOME /var/atlassian/application-data/jira +ENV JIRA_INSTALL_DIR /opt/atlassian/jira + +VOLUME ["${JIRA_HOME}"] +WORKDIR $JIRA_HOME + +# Expose HTTP port +EXPOSE 8080 + +################################################################## +# Installing +################################################################## +RUN mkdir -p ${JIRA_INSTALL_DIR} \ + && wget --random-wait --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36" -P /tmp/ ${DOWNLOAD_URL} \ + && tar -xzf /tmp/atlassian-jira-software-${RELEASE}.tar.gz --strip-components=1 -C "$JIRA_INSTALL_DIR" \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \ + && sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \ + && sed -i -e 's/grep "java version"/grep -E "(openjdk|java) version"/g' ${JIRA_INSTALL_DIR}/bin/check-java.sh \ + && sed -i -e 's/port="8080"/port="8080" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${JIRA_INSTALL_DIR}/conf/server.xml && \ + update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \ + apt clean -y && \ + apt autoclean -y && \ + rm -rfv /var/lib/apt/lists/* && \ + rm -rfv /var/cache/apt/archives/*.deb && \ + rm -rfv /tmp/* + +RUN updatedb + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh", "-fg"] +ENTRYPOINT ["/usr/bin/tini", "--"] diff --git a/linux/ecosystem/atlassian/jira/9/9.17.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.17.1/Makefile new file mode 100644 index 000000000..3383c9699 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.17.1/Makefile @@ -0,0 +1,50 @@ +PIP_BREAK_SYSTEM_PACKAGES=1 + +all: app + +app: + make build + make deploy + make clean + +build: + make pip + python3 kaniko-build.py --version + +dry: + make dry-run + +test: + make dry-run + +dry-run: + python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + +pip: + rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.7/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.8/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.9/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.12/EXTERNALLY-MANAGED + rm -rf /usr/lib/python3.13/EXTERNALLY-MANAGED + pip3 install -r requirements.txt + pip install -r requirements.txt + +build-compose: + docker-compose build --compress --parallel --progress plain + +deploy: + make pip + python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + +deploy-compose: + docker-compose push + +clean: + docker container prune -f + docker image prune -f + docker network prune -f + docker volume prune -f + docker system prune -af diff --git a/linux/ecosystem/atlassian/jira/9/9.17.1/docker-compose.yml b/linux/ecosystem/atlassian/jira/9/9.17.1/docker-compose.yml new file mode 100644 index 000000000..eb3277724 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.17.1/docker-compose.yml @@ -0,0 +1,17 @@ +#version: '3' +services: + app: + image: "epicmorg/jira:9.17.1" + build: + context: . + app-jdk11: + image: "epicmorg/jira:9.17.1-jdk11" + build: + context: . + dockerfile: Dockerfile.jdk11 + app-jdk17: + image: "epicmorg/jira:9.17.1-jdk17" + build: + context: . + dockerfile: Dockerfile.jdk17 + diff --git a/linux/ecosystem/atlassian/jira/9/9.17.1/entrypoint.sh b/linux/ecosystem/atlassian/jira/9/9.17.1/entrypoint.sh new file mode 100755 index 000000000..50ee4ecd1 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.17.1/entrypoint.sh @@ -0,0 +1,89 @@ +#!/bin/bash +set -euo pipefail + +export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") +export JRE_HOME="$JAVA_HOME/jre" +export JAVA_BINARY="$JRE_HOME/bin/java" +export JAVA_VERSION=$("$JAVA_BINARY" -version 2>&1 | awk -F '"' '/version/ {print $2}') + +# Setup Catalina Opts +: ${CATALINA_CONNECTOR_PROXYNAME:=} +: ${CATALINA_CONNECTOR_PROXYPORT:=} +: ${CATALINA_CONNECTOR_SCHEME:=http} +: ${CATALINA_CONNECTOR_SECURE:=false} + +: ${CATALINA_OPTS:=} + +: ${JAVA_OPTS:=} + +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyName=${CATALINA_CONNECTOR_PROXYNAME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyPort=${CATALINA_CONNECTOR_PROXYPORT}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorScheme=${CATALINA_CONNECTOR_SCHEME}" +CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorSecure=${CATALINA_CONNECTOR_SECURE}" + +export JAVA_OPTS="${JAVA_OPTS} ${CATALINA_OPTS}" + +# Setup Data Center configuration +if [ ! -f "/etc/container_id" ]; then + uuidgen > /etc/container_id +fi +CONTAINER_ID=$(cat /etc/container_id) +CONTAINER_SHORT_ID=${CONTAINER_ID::8} + +: ${CLUSTERED:=false} +: ${JIRA_NODE_ID:=jira_node_${CONTAINER_SHORT_ID}} +: ${JIRA_SHARED_HOME:=${JIRA_HOME}/shared} +: ${EHCACHE_PEER_DISCOVERY:=} +: ${EHCACHE_LISTENER_HOSTNAME:=} +: ${EHCACHE_LISTENER_PORT:=} +: ${EHCACHE_LISTENER_SOCKETTIMEOUTMILLIS:=} +: ${EHCACHE_MULTICAST_ADDRESS:=} +: ${EHCACHE_MULTICAST_PORT:=} +: ${EHCACHE_MULTICAST_TIMETOLIVE:=} +: ${EHCACHE_MULTICAST_HOSTNAME:=} + +# Cleanly set/unset values in cluster.properties +function set_cluster_property { + if [ -z $2 ]; then + if [ -f "${JIRA_HOME}/cluster.properties" ]; then + sed -i -e "/^${1}/d" "${JIRA_HOME}/cluster.properties" + fi + return + fi + if [ ! -f "${JIRA_HOME}/cluster.properties" ]; then + echo "${1}=${2}" >> "${JIRA_HOME}/cluster.properties" + elif grep "^${1}" "${JIRA_HOME}/cluster.properties"; then + sed -i -e "s#^${1}=.*#${1}=${2}#g" "${JIRA_HOME}/cluster.properties" + else + echo "${1}=${2}" >> "${JIRA_HOME}/cluster.properties" + fi +} + +if [ "${CLUSTERED}" == "true" ]; then + set_cluster_property "jira.node.id" "${JIRA_NODE_ID}" + set_cluster_property "jira.shared.home" "${JIRA_SHARED_HOME}" + set_cluster_property "ehcache.peer.discovery" "${EHCACHE_PEER_DISCOVERY}" + set_cluster_property "ehcache.listener.hostName" "${EHCACHE_LISTENER_HOSTNAME}" + set_cluster_property "ehcache.listener.port" "${EHCACHE_LISTENER_PORT}" + set_cluster_property "ehcache.listener.socketTimeoutMillis" "${EHCACHE_LISTENER_PORT}" + set_cluster_property "ehcache.multicast.address" "${EHCACHE_MULTICAST_ADDRESS}" + set_cluster_property "ehcache.multicast.port" "${EHCACHE_MULTICAST_PORT}" + set_cluster_property "ehcache.multicast.timeToLive" "${EHCACHE_MULTICAST_TIMETOLIVE}" + set_cluster_property "ehcache.multicast.hostName" "${EHCACHE_MULTICAST_HOSTNAME}" +fi + + +# Start Jira as the correct user +if [ "${UID}" -eq 0 ]; then + echo "User is currently root. Will change directory ownership to ${RUN_USER}:${RUN_GROUP}, then downgrade permission to ${RUN_USER}" + PERMISSIONS_SIGNATURE=$(stat -c "%u:%U:%a" "${JIRA_HOME}") + EXPECTED_PERMISSIONS=$(id -u ${RUN_USER}):${RUN_USER}:700 + if [ "${PERMISSIONS_SIGNATURE}" != "${EXPECTED_PERMISSIONS}" ]; then + chmod -R 700 "${JIRA_HOME}" && + chown -R "${RUN_USER}:${RUN_GROUP}" "${JIRA_HOME}" + fi + # Now drop privileges + exec su -s /bin/bash "${RUN_USER}" -c "$JIRA_INSTALL_DIR/bin/start-jira.sh $@" +else + exec "$JIRA_INSTALL_DIR/bin/start-jira.sh" "$@" +fi diff --git a/linux/ecosystem/atlassian/jira/9/9.17.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.17.1/kaniko-build.py new file mode 100644 index 000000000..e693b5c17 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.17.1/kaniko-build.py @@ -0,0 +1,196 @@ +import os +import shutil +import argparse +import yaml +import subprocess +from collections import defaultdict +from concurrent.futures import ThreadPoolExecutor, as_completed +from dotenv import load_dotenv +import logging +import sys + +# Script version +SCRIPT_VERSION = "1.0.1.0" + +# ASCII art for EpicMorg +ASCII_ART = r""" ++=================================================+ +| ____| _) \ | | +| __| __ \ | __| |\/ | _ \ __| _` | | +| | | | | ( | | ( | | ( | | +|_____| .__/ _| \___| _| _| \___/ _| \__, | | +| | / _| _) | |___/ | +| ' / _` | __ \ | | / _ \ | +| . \ ( | | | | < ( | | +|_|\_\ \__,_| _| _| _| _|\_\ \___/ | +|\ \ / | +| \ \ \ / __| _` | __ \ __ \ _ \ __|| +| \ \ \ / | ( | | | | | __/ | | +| \_/\_/ _| \__,_| .__/ .__/ \___| _| | +| _| _| | ++=================================================+ +""" + +# Load environment variables from .env file +load_dotenv() + +def setup_logging(): + logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + +def parse_args(): + parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) + parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') + parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') + parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') + parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') + parser.add_argument('--version', '-v', action='store_true', help='Show script version') + parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') + return parser.parse_args() + +def load_compose_file(file_path): + with open(file_path, 'r') as file: + return yaml.safe_load(file) + +def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): + kaniko_command = [ + 'docker', 'run', + '--rm', + '-t', + '-v', f'{os.path.abspath(build_context)}:/workspace', + ] + + # Add Docker config mounts for both read-only access + kaniko_command.extend([ + '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon + '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode + ]) + + kaniko_command.extend([ + kaniko_image, + '--context', '/workspace', + '--dockerfile', f'/workspace/{dockerfile}', + '--compressed-caching', + '--single-snapshot', + '--cleanup' + ]) + + if deploy: + kaniko_command.extend([ + '--destination', image_name + ]) + elif dry: + kaniko_command.extend([ + '--no-push' + ]) + else: + kaniko_command.extend([ + '--no-push' + ]) + + # Add build arguments if they exist + for arg_name, arg_value in build_args.items(): + kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) + + logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") + + process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + + # Stream output in real-time + for line in process.stdout: + logging.info(line.strip()) + + process.wait() + + if process.returncode == 0: + logging.info(f"Successfully built {service_name}") + else: + for line in process.stderr: + logging.error(line.strip()) + logging.error(f"Error building {service_name}") + raise Exception(f"Failed to build {service_name}") + +def show_help(): + print(ASCII_ART) + print("EpicMorg: Kaniko-Compose Wrapper\n") + print("Arguments:") + print("--compose-file Path to docker-compose.yml file") + print("--kaniko-image Kaniko executor image") + print("--push, --deploy, -d, -p Deploy the built images to the registry") + print("--dry-run, --dry Dry run: build images without pushing and with cleanup") + print("--version, -v Show script version") + print("--help, -h Show this help message and exit") + +def show_version(): + print(ASCII_ART) + print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") + +def main(): + setup_logging() + + args = parse_args() + + # Show help and exit if --help is provided + if args.help: + show_help() + return + + # Show version and exit if --version or no relevant arguments are provided + if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): + show_version() + return + + compose_file = args.compose_file + kaniko_image = args.kaniko_image + deploy = args.push + dry = args.dry_run + + if not os.path.exists(compose_file): + logging.error(f"{compose_file} not found") + return + + compose_data = load_compose_file(compose_file) + + services = compose_data.get('services', {}) + image_names = defaultdict(int) + + for service_name, service_data in services.items(): + image_name = service_data.get('image') + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + image_names[image_name] += 1 + + for image_name, count in image_names.items(): + if count > 1: + logging.error(f"Error: Image name {image_name} is used {count} times.") + return + + try: + with ThreadPoolExecutor() as executor: + futures = [] + for service_name, service_data in services.items(): + build_data = service_data.get('build', {}) + build_context = build_data.get('context', '.') + dockerfile = build_data.get('dockerfile', 'Dockerfile') + image_name = service_data.get('image') + build_args = build_data.get('args', {}) + + # Substitute environment variables with their values if they exist + build_args = {key: os.getenv(key, value) for key, value in build_args.items()} + + if not image_name: + logging.warning(f"No image specified for service {service_name}") + continue + + futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) + + for future in as_completed(futures): + future.result() + except Exception as exc: + logging.error(f"Build failed: {exc}") + sys.exit(1) + +if __name__ == '__main__': + main() diff --git a/linux/ecosystem/atlassian/jira/9/9.17.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.17.1/requirements.txt new file mode 100644 index 000000000..9ed771861 --- /dev/null +++ b/linux/ecosystem/atlassian/jira/9/9.17.1/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +python-dotenv diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/develop/Dockerfile b/linux/ecosystem/epicmorg/debian/12-bookworm/develop/Dockerfile index 223e4fc9d..3008dc1eb 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/develop/Dockerfile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/develop/Dockerfile @@ -826,7 +826,6 @@ RUN tar -xzf ${OPENSSL_111_TEMP} --directory /tmp && \ ln -sf ${OPENSSL_111_SRC_DIR} ${OPENSSL_111_DIR}/src && \ cd ${OPENSSL_111_TEMP_SRC} && \ ./config \ - no-shared \ zlib \ --with-zlib-include=${ZLIB_DIR}/include \ --with-zlib-lib=${ZLIB_DIR}/lib \ @@ -852,7 +851,6 @@ RUN tar -xzf ${OPENSSL_30_TEMP} --directory /tmp && \ ln -sf ${OPENSSL_30_SRC_DIR} ${OPENSSL_30_DIR}/src && \ cd ${OPENSSL_30_TEMP_SRC} && \ ./config \ - no-shared \ zlib \ --with-zlib-include=${ZLIB_DIR}/include \ --with-zlib-lib=${ZLIB_DIR}/lib \ @@ -881,7 +879,6 @@ RUN tar -xzf ${OPENSSL_31_TEMP} --directory /tmp && \ ln -sf ${OPENSSL_31_SRC_DIR} ${OPENSSL_31_DIR}/src && \ cd ${OPENSSL_31_TEMP_SRC} && \ ./config \ - no-shared \ zlib \ --with-zlib-include=${ZLIB_DIR}/include \ --with-zlib-lib=${ZLIB_DIR}/lib \ @@ -910,7 +907,6 @@ RUN tar -xzf ${OPENSSL_32_TEMP} --directory /tmp && \ ln -sf ${OPENSSL_32_SRC_DIR} ${OPENSSL_32_DIR}/src && \ cd ${OPENSSL_32_TEMP_SRC} && \ ./config \ - no-shared \ zlib \ --with-zlib-include=${ZLIB_DIR}/include \ --with-zlib-lib=${ZLIB_DIR}/lib \ @@ -941,7 +937,6 @@ RUN tar -xzf ${OPENSSL_33_TEMP} --directory /tmp && \ ln -sf ${OPENSSL_33_SRC_DIR} ${OPENSSL_33_DIR}/src && \ cd ${OPENSSL_33_TEMP_SRC} && \ ./config \ - no-shared \ zlib \ --with-zlib-include=${ZLIB_DIR}/include \ --with-zlib-lib=${ZLIB_DIR}/lib \ @@ -984,10 +979,10 @@ RUN tar -xzf ${LIBRESSL_TEMP} --directory /tmp && \ && \ make -j$(nproc) && \ make -j$(nproc) install && \ - ln -sfv ${LIBRESSL_INC_DIR}/* /usr/local/include && \ - ln -sfv ${LIBRESSL_LIB_DIR}/* /usr/local/lib && \ - echo "# LibreSSL support" >> ${LD_CONF_DIR}/LibreSSL.conf && \ - echo ${LIBRESSL_LIB_DIR} >> ${LD_CONF_DIR}/LibreSSL.conf && \ +# ln -sfv ${LIBRESSL_INC_DIR}/* /usr/local/include && \ +# ln -sfv ${LIBRESSL_LIB_DIR}/* /usr/local/lib && \ +# echo "# LibreSSL support" >> ${LD_CONF_DIR}/LibreSSL.conf && \ +# echo ${LIBRESSL_LIB_DIR} >> ${LD_CONF_DIR}/LibreSSL.conf && \ ldconfig ################################################################## @@ -1000,13 +995,13 @@ RUN mkdir -p ${BORINGSSL_DIR} ${BORINGSSL_SRC_DIR} && \ cd ${BORINGSSL_TEMP_SRC} && \ mkdir ${BORINGSSL_TEMP_SRC}/build && \ cd ${BORINGSSL_TEMP_SRC}/build && \ - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=${BORINGSSL_DIR} .. && \ + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_PREFIX=${BORINGSSL_DIR} .. && \ make -j$(if [ $(nproc) -gt 8 ]; then echo $(( $(nproc) / 2 )); else echo $(nproc); fi) && \ make -j$(nproc) install && \ - ln -sfv ${BORINGSSL_INC_DIR}/* /usr/local/include && \ - ln -sfv ${BORINGSSL_LIB_DIR}/* /usr/local/lib && \ - echo "# BoringSSL support" >> ${LD_CONF_DIR}/BoringSSL.conf && \ - echo ${BORINGSSL_LIB_DIR} >> ${LD_CONF_DIR}/BoringSSL.conf && \ +# ln -sfv ${BORINGSSL_INC_DIR}/* /usr/local/include && \ +# ln -sfv ${BORINGSSL_LIB_DIR}/* /usr/local/lib && \ +# echo "# BoringSSL support" >> ${LD_CONF_DIR}/BoringSSL.conf && \ +# echo ${BORINGSSL_LIB_DIR} >> ${LD_CONF_DIR}/BoringSSL.conf && \ ldconfig ################################################################## diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/Dockerfile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/Dockerfile index 0d6c19037..0a8e7374e 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/Dockerfile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/Dockerfile @@ -10,6 +10,7 @@ ARG K_JDK_URL=https://github.com/adoptium/temurin${K_JDK_MAJOR_VERSION}-binaries ARG K_JDK_TEMP=/tmp/OpenJDK${K_JDK_MAJOR_VERSION}U-jdk_x64_linux_hotspot_${K_JDK_VERSION}_${K_JDK_BUILD_VERSION}.tar.gz ENV JAVA_HOME=/usr/local/${K_JDK_FULL_VERSION}+${K_JDK_BUILD_VERSION} +ENV JRE_HOME=${JAVA_HOME} ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## @@ -17,6 +18,7 @@ ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## ADD ${K_JDK_URL} /tmp RUN tar -xvzf ${K_JDK_TEMP} --directory /usr/local && \ + ln -sfv ${JAVA_HOME} /usr/jre && \ java -version ################################################################## diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/Dockerfile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/Dockerfile index 0f5c1ec36..d9beacbf9 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/Dockerfile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/Dockerfile @@ -10,6 +10,7 @@ ARG K_JDK_URL=https://github.com/adoptium/temurin${K_JDK_MAJOR_VERSION}-binaries ARG K_JDK_TEMP=/tmp/OpenJDK${K_JDK_MAJOR_VERSION}U-jdk_x64_linux_hotspot_${K_JDK_VERSION}_${K_JDK_BUILD_VERSION}.tar.gz ENV JAVA_HOME=/usr/local/${K_JDK_FULL_VERSION}+${K_JDK_BUILD_VERSION} +ENV JRE_HOME=${JAVA_HOME} ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## @@ -17,6 +18,7 @@ ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## ADD ${K_JDK_URL} /tmp RUN tar -xvzf ${K_JDK_TEMP} --directory /usr/local && \ + ln -sfv ${JAVA_HOME} /usr/jre && \ java -version ################################################################## diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/Dockerfile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/Dockerfile index 5db4e54e7..e64989901 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/Dockerfile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/Dockerfile @@ -10,6 +10,7 @@ ARG K_JDK_URL=https://github.com/adoptium/temurin${K_JDK_MAJOR_VERSION}-binaries ARG K_JDK_TEMP=/tmp/OpenJDK${K_JDK_MAJOR_VERSION}U-jdk_x64_linux_hotspot_${K_JDK_VERSION}_${K_JDK_BUILD_VERSION}.tar.gz ENV JAVA_HOME=/usr/local/${K_JDK_FULL_VERSION}+${K_JDK_BUILD_VERSION} +ENV JRE_HOME=${JAVA_HOME} ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## @@ -17,6 +18,7 @@ ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## ADD ${K_JDK_URL} /tmp RUN tar -xvzf ${K_JDK_TEMP} --directory /usr/local && \ + ln -sfv ${JAVA_HOME} /usr/jre && \ java -version ################################################################## diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/Dockerfile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/Dockerfile index 5c816e1ad..ac24ef73a 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/Dockerfile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/Dockerfile @@ -10,6 +10,7 @@ ARG K_JDK_URL=https://github.com/adoptium/temurin${K_JDK_MAJOR_VERSION}-binaries ARG K_JDK_TEMP=/tmp/OpenJDK${K_JDK_MAJOR_VERSION}U-jdk_x64_linux_hotspot_${K_JDK_VERSION}_${K_JDK_BUILD_VERSION}.tar.gz ENV JAVA_HOME=/usr/local/${K_JDK_FULL_VERSION}+${K_JDK_BUILD_VERSION} +ENV JRE_HOME=${JAVA_HOME} ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## @@ -17,6 +18,7 @@ ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## ADD ${K_JDK_URL} /tmp RUN tar -xvzf ${K_JDK_TEMP} --directory /usr/local && \ + ln -sfv ${JAVA_HOME} /usr/jre && \ java -version ################################################################## diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/Dockerfile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/Dockerfile index b3d62d8bc..855b4e713 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/Dockerfile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/Dockerfile @@ -10,6 +10,7 @@ ARG K_JDK_URL=https://github.com/adoptium/temurin${K_JDK_MAJOR_VERSION}-binaries ARG K_JDK_TEMP=/tmp/OpenJDK${K_JDK_MAJOR_VERSION}U-jdk_x64_linux_hotspot_${K_JDK_VERSION}_${K_JDK_BUILD_VERSION}.tar.gz ENV JAVA_HOME=/usr/local/${K_JDK_FULL_VERSION}+${K_JDK_BUILD_VERSION} +ENV JRE_HOME=${JAVA_HOME} ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## @@ -17,6 +18,7 @@ ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## ADD ${K_JDK_URL} /tmp RUN tar -xvzf ${K_JDK_TEMP} --directory /usr/local && \ + ln -sfv ${JAVA_HOME} /usr/jre && \ java -version ################################################################## diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/Dockerfile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/Dockerfile index e32acfb61..c7e2b4644 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/Dockerfile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/Dockerfile @@ -10,6 +10,7 @@ ARG K_JDK_URL=https://github.com/adoptium/temurin${K_JDK_MAJOR_VERSION}-binaries ARG K_JDK_TEMP=/tmp/OpenJDK${K_JDK_MAJOR_VERSION}U-jdk_x64_linux_hotspot_${K_JDK_VERSION}_${K_JDK_BUILD_VERSION}.tar.gz ENV JAVA_HOME=/usr/local/${K_JDK_FULL_VERSION}+${K_JDK_BUILD_VERSION} +ENV JRE_HOME=${JAVA_HOME} ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## @@ -17,6 +18,7 @@ ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## ADD ${K_JDK_URL} /tmp RUN tar -xvzf ${K_JDK_TEMP} --directory /usr/local && \ + ln -sfv ${JAVA_HOME} /usr/jre && \ java -version ################################################################## diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/Dockerfile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/Dockerfile index 268dea24d..1263724c0 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/Dockerfile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/Dockerfile @@ -10,6 +10,7 @@ ARG K_JDK_URL=https://github.com/adoptium/temurin${K_JDK_MAJOR_VERSION}-binaries ARG K_JDK_TEMP=/tmp/OpenJDK${K_JDK_MAJOR_VERSION}U-jdk_x64_linux_hotspot_${K_JDK_VERSION}_${K_JDK_BUILD_VERSION}.tar.gz ENV JAVA_HOME=/usr/local/${K_JDK_FULL_VERSION}+${K_JDK_BUILD_VERSION} +ENV JRE_HOME=${JAVA_HOME} ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## @@ -17,6 +18,7 @@ ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## ADD ${K_JDK_URL} /tmp RUN tar -xvzf ${K_JDK_TEMP} --directory /usr/local && \ + ln -sfv ${JAVA_HOME} /usr/jre && \ java -version ################################################################## diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/Dockerfile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/Dockerfile index f052bd6cc..c3c111232 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/Dockerfile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/Dockerfile @@ -10,6 +10,7 @@ ARG K_JDK_URL=https://github.com/adoptium/temurin${K_JDK_MAJOR_VERSION}-binaries ARG K_JDK_TEMP=/tmp/OpenJDK${K_JDK_MAJOR_VERSION}U-jdk_x64_linux_hotspot_${K_JDK_VERSION}_${K_JDK_BUILD_VERSION}.tar.gz ENV JAVA_HOME=/usr/local/${K_JDK_FULL_VERSION}+${K_JDK_BUILD_VERSION} +ENV JRE_HOME=${JAVA_HOME} ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## @@ -17,6 +18,7 @@ ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## ADD ${K_JDK_URL} /tmp RUN tar -xvzf ${K_JDK_TEMP} --directory /usr/local && \ + ln -sfv ${JAVA_HOME} /usr/jre && \ java -version ################################################################## diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/Dockerfile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/Dockerfile index 959a7b44e..f3b17c23c 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/Dockerfile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/Dockerfile @@ -8,6 +8,7 @@ ARG K_JDK_URL=http://cdn.azul.com/zulu/bin/zulu${K_JDK_VERSION}-jdk${K_JDK_BUILD ARG K_JDK_TEMP=/tmp/zulu${K_JDK_VERSION}-jdk${K_JDK_BUILD_VERSION}-linux_x64.tar.gz ENV JAVA_HOME=/usr/local/zulu${K_JDK_VERSION}-jdk${K_JDK_BUILD_VERSION}-linux_x64 +ENV JRE_HOME=${JAVA_HOME} ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## @@ -15,6 +16,7 @@ ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## ADD ${K_JDK_URL} /tmp RUN tar -xvzf /tmp/zulu${K_JDK_VERSION}-jdk${K_JDK_BUILD_VERSION}-linux_x64.tar.gz --directory /usr/local && \ + ln -sfv ${JAVA_HOME} /usr/jre && \ java -version ################################################################## diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/Dockerfile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/Dockerfile index 8798aae63..d0641a7f9 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/Dockerfile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/Dockerfile @@ -8,6 +8,7 @@ ARG K_JDK_URL=http://cdn.azul.com/zulu/bin/zulu${K_JDK_VERSION}-ca-jdk${K_JDK_BU ARG K_JDK_TEMP=/tmp/zulu${K_JDK_VERSION}-ca-jdk${K_JDK_BUILD_VERSION}-linux_x64.tar.gz ENV JAVA_HOME=/usr/local/zulu${K_JDK_VERSION}-ca-jdk${K_JDK_BUILD_VERSION}-linux_x64 +ENV JRE_HOME=${JAVA_HOME} ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## @@ -15,6 +16,7 @@ ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## ADD ${K_JDK_URL} /tmp RUN tar -xvzf ${K_JDK_TEMP} --directory /usr/local && \ + ln -sfv ${JAVA_HOME} /usr/jre && \ java -version ################################################################## diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/Dockerfile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/Dockerfile index d4b18405a..b0a60c1e6 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/Dockerfile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/Dockerfile @@ -10,6 +10,7 @@ ARG K_JDK_URL=https://github.com/adoptium/temurin${K_JDK_MAJOR_VERSION}-binaries ARG K_JDK_TEMP=/tmp/OpenJDK${K_JDK_MAJOR_VERSION}U-jdk_x64_linux_hotspot_${K_JDK_VERSION}${K_JDK_BUILD_VERSION}.tar.gz ENV JAVA_HOME=/usr/local/${K_JDK_FULL_VERSION}-${K_JDK_BUILD_VERSION} +ENV JRE_HOME=${JAVA_HOME} ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## @@ -17,6 +18,7 @@ ENV PATH=$PATH:${JAVA_HOME}/bin ################################################################## ADD ${K_JDK_URL} /tmp RUN tar -xvzf ${K_JDK_TEMP} --directory /usr/local && \ + ln -sfv ${JAVA_HOME} /usr/jre && \ java -version ################################################################## diff --git a/linux/ecosystem/nginx/1.27.0/main/Dockerfile b/linux/ecosystem/nginx/1.27.0/main/Dockerfile index 4dacd7b7e..2d46986de 100644 --- a/linux/ecosystem/nginx/1.27.0/main/Dockerfile +++ b/linux/ecosystem/nginx/1.27.0/main/Dockerfile @@ -271,7 +271,7 @@ RUN cp -rf ${NGINX_TEMP_SRC}/* ${NGINX_SRC_DIR} && \ ## gd fuck ## --with-http_image_filter_module \ ## perftools fuck - --with-google_perftools_module \ +## --with-google_perftools_module \ ## perl problem fuck ## --with-http_perl_module \ ## @@ -291,7 +291,8 @@ RUN cp -rf ${NGINX_TEMP_SRC}/* ${NGINX_SRC_DIR} && \ ## undefined reference to `sasl_getprop' ## --add-module=modules/http-auth-ldap \ && \ - make -j$(nproc) && make install + make -j$(nproc) && \ + make -j$(nproc) install RUN rm -rfv ${NGINX_CONF_DIR}/nginx.conf && \ mkdir -p ${NGINX_MODULES_DIR} ${NGINX_MODULES_PERL_DIR} @@ -397,6 +398,5 @@ RUN nginx -V CMD ["nginx", "-g", "daemon off;"] #TODO: -# fix and redeploy develop (blocker!) +# fix and redeploy develop (blocker!) -- DONE # add link to /usr/src/nginx/ -> /src folder to final layer -# xz files in /usr/src/nginx/ folder to optimize size From 202e7685667d6a3885d43064b28e8c8188b71ede Mon Sep 17 00:00:00 2001 From: STAM Date: Sat, 10 Aug 2024 21:36:22 +0300 Subject: [PATCH 2/2] kaniko migrated to pip package --- .../roles/atlassian.bitbucket/files/Makefile | 6 +- .../atlassian.bitbucket/files/kaniko-build.py | 194 ----------------- .../roles/atlassian.jira/files/Makefile | 6 +- .../atlassian.jira/files/kaniko-build.py | 194 ----------------- .../gurock.testrail/files/php70/ad/Makefile | 6 +- .../files/php70/ad/kaniko-build.py | 194 ----------------- .../gurock.testrail/files/php70/ldap/Makefile | 6 +- .../files/php70/ldap/kaniko-build.py | 194 ----------------- .../gurock.testrail/files/php70/main/Makefile | 6 +- .../files/php70/main/kaniko-build.py | 194 ----------------- .../gurock.testrail/files/php71/ad/Makefile | 6 +- .../files/php71/ad/kaniko-build.py | 194 ----------------- .../gurock.testrail/files/php71/ldap/Makefile | 6 +- .../files/php71/ldap/kaniko-build.py | 194 ----------------- .../gurock.testrail/files/php71/main/Makefile | 6 +- .../files/php71/main/kaniko-build.py | 194 ----------------- .../gurock.testrail/files/php72/ad/Makefile | 6 +- .../files/php72/ad/kaniko-build.py | 194 ----------------- .../gurock.testrail/files/php72/ldap/Makefile | 6 +- .../files/php72/ldap/kaniko-build.py | 194 ----------------- .../gurock.testrail/files/php72/main/Makefile | 6 +- .../files/php72/main/kaniko-build.py | 194 ----------------- .../gurock.testrail/files/php74/ad/Makefile | 6 +- .../files/php74/ad/kaniko-build.py | 194 ----------------- .../gurock.testrail/files/php74/ldap/Makefile | 6 +- .../files/php74/ldap/kaniko-build.py | 194 ----------------- .../gurock.testrail/files/php74/main/Makefile | 6 +- .../files/php74/main/kaniko-build.py | 194 ----------------- .../gurock.testrail/files/php81/ad/Makefile | 6 +- .../files/php81/ad/kaniko-build.py | 194 ----------------- .../gurock.testrail/files/php81/ldap/Makefile | 6 +- .../files/php81/ldap/kaniko-build.py | 194 ----------------- .../gurock.testrail/files/php81/main/Makefile | 6 +- .../files/php81/main/kaniko-build.py | 194 ----------------- bin/kaniko/_deploy.py | 2 +- bin/kaniko/kaniko-build.py | 196 ------------------ bin/kaniko/requirements.txt | 1 + linux/advanced/mattermost/Makefile | 6 +- linux/advanced/mattermost/kaniko-build.py | 196 ------------------ linux/advanced/mattermost/requirements.txt | 1 + linux/advanced/nextcloud/patched/14/Makefile | 6 +- .../nextcloud/patched/14/kaniko-build.py | 196 ------------------ .../nextcloud/patched/14/requirements.txt | 1 + linux/advanced/nextcloud/patched/15/Makefile | 6 +- .../nextcloud/patched/15/kaniko-build.py | 196 ------------------ .../nextcloud/patched/15/requirements.txt | 1 + linux/advanced/nextcloud/patched/16/Makefile | 6 +- .../nextcloud/patched/16/kaniko-build.py | 196 ------------------ .../nextcloud/patched/16/requirements.txt | 1 + linux/advanced/nextcloud/patched/17/Makefile | 6 +- .../nextcloud/patched/17/kaniko-build.py | 196 ------------------ .../nextcloud/patched/17/requirements.txt | 1 + linux/advanced/nextcloud/patched/18/Makefile | 6 +- .../nextcloud/patched/18/kaniko-build.py | 196 ------------------ .../nextcloud/patched/18/requirements.txt | 1 + linux/advanced/nextcloud/patched/19/Makefile | 6 +- .../nextcloud/patched/19/kaniko-build.py | 196 ------------------ .../nextcloud/patched/19/requirements.txt | 1 + linux/advanced/nextcloud/patched/20/Makefile | 6 +- .../nextcloud/patched/20/kaniko-build.py | 196 ------------------ .../nextcloud/patched/20/requirements.txt | 1 + linux/advanced/nextcloud/patched/21/Makefile | 6 +- .../nextcloud/patched/21/kaniko-build.py | 196 ------------------ .../nextcloud/patched/21/requirements.txt | 1 + linux/advanced/nextcloud/patched/22/Makefile | 6 +- .../nextcloud/patched/22/kaniko-build.py | 196 ------------------ .../nextcloud/patched/22/requirements.txt | 1 + linux/advanced/nextcloud/patched/23/Makefile | 6 +- .../nextcloud/patched/23/kaniko-build.py | 196 ------------------ .../nextcloud/patched/23/requirements.txt | 1 + linux/advanced/nextcloud/patched/24/Makefile | 6 +- .../nextcloud/patched/24/kaniko-build.py | 196 ------------------ .../nextcloud/patched/24/requirements.txt | 1 + linux/advanced/nextcloud/patched/25/Makefile | 6 +- .../nextcloud/patched/25/kaniko-build.py | 196 ------------------ .../nextcloud/patched/25/requirements.txt | 1 + linux/advanced/nextcloud/patched/26/Makefile | 6 +- .../nextcloud/patched/26/kaniko-build.py | 196 ------------------ .../nextcloud/patched/26/requirements.txt | 1 + linux/advanced/nextcloud/patched/27/Makefile | 6 +- .../nextcloud/patched/27/kaniko-build.py | 196 ------------------ .../nextcloud/patched/27/requirements.txt | 1 + linux/advanced/nextcloud/patched/28/Makefile | 6 +- .../nextcloud/patched/28/kaniko-build.py | 196 ------------------ .../nextcloud/patched/28/requirements.txt | 1 + linux/advanced/nextcloud/patched/29/Makefile | 6 +- .../nextcloud/patched/29/kaniko-build.py | 196 ------------------ .../nextcloud/patched/29/requirements.txt | 1 + .../nextcloud/patched/latest/Makefile | 6 +- .../nextcloud/patched/latest/kaniko-build.py | 196 ------------------ .../nextcloud/patched/latest/requirements.txt | 1 + linux/advanced/nextcloud/pure/14/Makefile | 6 +- .../nextcloud/pure/14/kaniko-build.py | 196 ------------------ .../nextcloud/pure/14/requirements.txt | 1 + linux/advanced/nextcloud/pure/15/Makefile | 6 +- .../nextcloud/pure/15/kaniko-build.py | 196 ------------------ .../nextcloud/pure/15/requirements.txt | 1 + linux/advanced/nextcloud/pure/16/Makefile | 6 +- .../nextcloud/pure/16/kaniko-build.py | 196 ------------------ .../nextcloud/pure/16/requirements.txt | 1 + linux/advanced/nextcloud/pure/17/Makefile | 6 +- .../nextcloud/pure/17/kaniko-build.py | 196 ------------------ .../nextcloud/pure/17/requirements.txt | 1 + linux/advanced/nextcloud/pure/18/Makefile | 6 +- .../nextcloud/pure/18/kaniko-build.py | 196 ------------------ .../nextcloud/pure/18/requirements.txt | 1 + linux/advanced/nextcloud/pure/19/Makefile | 6 +- .../nextcloud/pure/19/kaniko-build.py | 196 ------------------ .../nextcloud/pure/19/requirements.txt | 1 + linux/advanced/nextcloud/pure/20/Makefile | 6 +- .../nextcloud/pure/20/kaniko-build.py | 196 ------------------ .../nextcloud/pure/20/requirements.txt | 1 + linux/advanced/nextcloud/pure/21/Makefile | 6 +- .../nextcloud/pure/21/kaniko-build.py | 196 ------------------ .../nextcloud/pure/21/requirements.txt | 1 + linux/advanced/nextcloud/pure/22/Makefile | 6 +- .../nextcloud/pure/22/kaniko-build.py | 196 ------------------ .../nextcloud/pure/22/requirements.txt | 1 + linux/advanced/nextcloud/pure/23/Makefile | 6 +- .../nextcloud/pure/23/kaniko-build.py | 196 ------------------ .../nextcloud/pure/23/requirements.txt | 1 + linux/advanced/nextcloud/pure/24/Makefile | 6 +- .../nextcloud/pure/24/kaniko-build.py | 196 ------------------ .../nextcloud/pure/24/requirements.txt | 1 + linux/advanced/nextcloud/pure/25/Makefile | 6 +- .../nextcloud/pure/25/kaniko-build.py | 196 ------------------ .../nextcloud/pure/25/requirements.txt | 1 + linux/advanced/nextcloud/pure/26/Makefile | 6 +- .../nextcloud/pure/26/kaniko-build.py | 196 ------------------ .../nextcloud/pure/26/requirements.txt | 1 + linux/advanced/nextcloud/pure/27/Makefile | 6 +- .../nextcloud/pure/27/kaniko-build.py | 196 ------------------ .../nextcloud/pure/27/requirements.txt | 1 + linux/advanced/nextcloud/pure/28/Makefile | 6 +- .../nextcloud/pure/28/kaniko-build.py | 196 ------------------ .../nextcloud/pure/28/requirements.txt | 1 + linux/advanced/nextcloud/pure/29/Makefile | 6 +- .../nextcloud/pure/29/kaniko-build.py | 196 ------------------ .../nextcloud/pure/29/requirements.txt | 1 + linux/advanced/nextcloud/pure/latest/Makefile | 6 +- .../nextcloud/pure/latest/kaniko-build.py | 196 ------------------ .../nextcloud/pure/latest/requirements.txt | 1 + linux/advanced/python/develop/2.7/Makefile | 6 +- .../python/develop/2.7/kaniko-build.py | 196 ------------------ .../python/develop/2.7/requirements.txt | 1 + linux/advanced/python/develop/3.10/Makefile | 6 +- .../python/develop/3.10/kaniko-build.py | 196 ------------------ .../python/develop/3.10/requirements.txt | 1 + linux/advanced/python/develop/3.11/Makefile | 6 +- .../python/develop/3.11/kaniko-build.py | 196 ------------------ .../python/develop/3.11/requirements.txt | 1 + linux/advanced/python/develop/3.12/Makefile | 6 +- .../python/develop/3.12/kaniko-build.py | 196 ------------------ .../python/develop/3.12/requirements.txt | 1 + linux/advanced/python/develop/3.13/Makefile | 6 +- .../python/develop/3.13/kaniko-build.py | 196 ------------------ .../python/develop/3.13/requirements.txt | 1 + linux/advanced/python/develop/3.6/Makefile | 6 +- .../python/develop/3.6/kaniko-build.py | 196 ------------------ .../python/develop/3.6/requirements.txt | 1 + linux/advanced/python/develop/3.7/Makefile | 6 +- .../python/develop/3.7/kaniko-build.py | 196 ------------------ .../python/develop/3.7/requirements.txt | 1 + linux/advanced/python/develop/3.8/Makefile | 6 +- .../python/develop/3.8/kaniko-build.py | 196 ------------------ .../python/develop/3.8/requirements.txt | 1 + linux/advanced/python/develop/3.9/Makefile | 6 +- .../python/develop/3.9/kaniko-build.py | 196 ------------------ .../python/develop/3.9/requirements.txt | 1 + linux/advanced/python/main/2.7/Makefile | 6 +- .../advanced/python/main/2.7/kaniko-build.py | 196 ------------------ .../advanced/python/main/2.7/requirements.txt | 1 + linux/advanced/python/main/3.10/Makefile | 6 +- .../advanced/python/main/3.10/kaniko-build.py | 196 ------------------ .../python/main/3.10/requirements.txt | 1 + linux/advanced/python/main/3.11/Makefile | 6 +- .../advanced/python/main/3.11/kaniko-build.py | 196 ------------------ .../python/main/3.11/requirements.txt | 1 + linux/advanced/python/main/3.12/Makefile | 6 +- .../advanced/python/main/3.12/kaniko-build.py | 196 ------------------ .../python/main/3.12/requirements.txt | 1 + linux/advanced/python/main/3.13/Makefile | 6 +- .../advanced/python/main/3.13/kaniko-build.py | 196 ------------------ .../python/main/3.13/requirements.txt | 1 + linux/advanced/python/main/3.6/Makefile | 6 +- .../advanced/python/main/3.6/kaniko-build.py | 196 ------------------ .../advanced/python/main/3.6/requirements.txt | 1 + linux/advanced/python/main/3.7/Makefile | 6 +- .../advanced/python/main/3.7/kaniko-build.py | 196 ------------------ .../advanced/python/main/3.7/requirements.txt | 1 + linux/advanced/python/main/3.8/Makefile | 6 +- .../advanced/python/main/3.8/kaniko-build.py | 196 ------------------ .../advanced/python/main/3.8/requirements.txt | 1 + linux/advanced/python/main/3.9/Makefile | 6 +- .../advanced/python/main/3.9/kaniko-build.py | 196 ------------------ .../advanced/python/main/3.9/requirements.txt | 1 + linux/advanced/redash/Makefile | 6 +- linux/advanced/sentry/latest/Makefile | 6 +- linux/advanced/sentry/latest/kaniko-build.py | 196 ------------------ linux/advanced/sentry/latest/requirements.txt | 1 + linux/advanced/teamcity/server/Makefile | 6 +- .../advanced/teamcity/server/kaniko-build.py | 196 ------------------ .../advanced/teamcity/server/requirements.txt | 1 + .../advanced/vscode-server/amxx/1.10/Makefile | 6 +- .../vscode-server/amxx/1.10/kaniko-build.py | 196 ------------------ .../vscode-server/amxx/1.10/requirements.txt | 1 + .../advanced/vscode-server/amxx/1.9/Makefile | 6 +- .../vscode-server/amxx/1.9/kaniko-build.py | 196 ------------------ .../vscode-server/amxx/1.9/requirements.txt | 1 + linux/advanced/vscode-server/android/Makefile | 6 +- .../vscode-server/android/kaniko-build.py | 196 ------------------ .../vscode-server/android/requirements.txt | 1 + linux/advanced/vscode-server/cpp/Makefile | 6 +- .../vscode-server/cpp/kaniko-build.py | 196 ------------------ .../vscode-server/cpp/requirements.txt | 1 + linux/advanced/vscode-server/devops/Makefile | 6 +- .../vscode-server/devops/kaniko-build.py | 196 ------------------ .../vscode-server/devops/requirements.txt | 1 + linux/advanced/vscode-server/docker/Makefile | 6 +- .../vscode-server/docker/kaniko-build.py | 196 ------------------ .../vscode-server/docker/requirements.txt | 1 + .../vscode-server/dotnet-full/Makefile | 6 +- .../vscode-server/dotnet-full/kaniko-build.py | 196 ------------------ .../dotnet-full/requirements.txt | 1 + linux/advanced/vscode-server/dotnet/Makefile | 6 +- .../vscode-server/dotnet/kaniko-build.py | 196 ------------------ .../vscode-server/dotnet/requirements.txt | 1 + linux/advanced/vscode-server/latest/Makefile | 6 +- .../vscode-server/latest/kaniko-build.py | 196 ------------------ .../vscode-server/latest/requirements.txt | 1 + linux/advanced/vscode-server/mono/Makefile | 6 +- .../vscode-server/mono/kaniko-build.py | 196 ------------------ .../vscode-server/mono/requirements.txt | 1 + linux/advanced/zabbix/3.0/agent/Makefile | 6 +- .../advanced/zabbix/3.0/agent/kaniko-build.py | 196 ------------------ .../zabbix/3.0/agent/requirements.txt | 1 + .../advanced/zabbix/3.0/java-gateway/Makefile | 6 +- .../zabbix/3.0/java-gateway/kaniko-build.py | 196 ------------------ .../zabbix/3.0/java-gateway/requirements.txt | 1 + .../advanced/zabbix/3.0/proxy-mysql/Makefile | 6 +- .../zabbix/3.0/proxy-mysql/kaniko-build.py | 196 ------------------ .../zabbix/3.0/proxy-mysql/requirements.txt | 1 + .../zabbix/3.0/proxy-sqlite3/Makefile | 6 +- .../zabbix/3.0/proxy-sqlite3/kaniko-build.py | 196 ------------------ .../zabbix/3.0/proxy-sqlite3/requirements.txt | 1 + .../advanced/zabbix/3.0/server-mysql/Makefile | 6 +- .../zabbix/3.0/server-mysql/kaniko-build.py | 196 ------------------ .../zabbix/3.0/server-mysql/requirements.txt | 1 + .../advanced/zabbix/3.0/server-pgsql/Makefile | 6 +- .../zabbix/3.0/server-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/3.0/server-pgsql/requirements.txt | 1 + linux/advanced/zabbix/3.0/snmptraps/Makefile | 6 +- .../zabbix/3.0/snmptraps/kaniko-build.py | 196 ------------------ .../zabbix/3.0/snmptraps/requirements.txt | 1 + linux/advanced/zabbix/3.0/web-mysql/Makefile | 6 +- .../zabbix/3.0/web-mysql/kaniko-build.py | 196 ------------------ .../zabbix/3.0/web-mysql/requirements.txt | 1 + linux/advanced/zabbix/3.0/web-pgsql/Makefile | 6 +- .../zabbix/3.0/web-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/3.0/web-pgsql/requirements.txt | 1 + linux/advanced/zabbix/4.0/agent/Makefile | 6 +- .../advanced/zabbix/4.0/agent/kaniko-build.py | 196 ------------------ .../zabbix/4.0/agent/requirements.txt | 1 + .../advanced/zabbix/4.0/java-gateway/Makefile | 6 +- .../zabbix/4.0/java-gateway/kaniko-build.py | 196 ------------------ .../zabbix/4.0/java-gateway/requirements.txt | 1 + .../advanced/zabbix/4.0/proxy-mysql/Makefile | 6 +- .../zabbix/4.0/proxy-mysql/kaniko-build.py | 196 ------------------ .../zabbix/4.0/proxy-mysql/requirements.txt | 1 + .../zabbix/4.0/proxy-sqlite3/Makefile | 6 +- .../zabbix/4.0/proxy-sqlite3/kaniko-build.py | 196 ------------------ .../zabbix/4.0/proxy-sqlite3/requirements.txt | 1 + .../advanced/zabbix/4.0/server-mysql/Makefile | 6 +- .../zabbix/4.0/server-mysql/kaniko-build.py | 196 ------------------ .../zabbix/4.0/server-mysql/requirements.txt | 1 + .../advanced/zabbix/4.0/server-pgsql/Makefile | 6 +- .../zabbix/4.0/server-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/4.0/server-pgsql/requirements.txt | 1 + linux/advanced/zabbix/4.0/snmptraps/Makefile | 6 +- .../zabbix/4.0/snmptraps/kaniko-build.py | 196 ------------------ .../zabbix/4.0/snmptraps/requirements.txt | 1 + linux/advanced/zabbix/4.0/web-mysql/Makefile | 6 +- .../zabbix/4.0/web-mysql/kaniko-build.py | 196 ------------------ .../zabbix/4.0/web-mysql/requirements.txt | 1 + linux/advanced/zabbix/4.0/web-pgsql/Makefile | 6 +- .../zabbix/4.0/web-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/4.0/web-pgsql/requirements.txt | 1 + linux/advanced/zabbix/5.0/agent/Makefile | 6 +- .../advanced/zabbix/5.0/agent/kaniko-build.py | 196 ------------------ .../zabbix/5.0/agent/requirements.txt | 1 + linux/advanced/zabbix/5.0/agent2/Makefile | 6 +- .../zabbix/5.0/agent2/kaniko-build.py | 196 ------------------ .../zabbix/5.0/agent2/requirements.txt | 1 + .../advanced/zabbix/5.0/java-gateway/Makefile | 6 +- .../zabbix/5.0/java-gateway/kaniko-build.py | 196 ------------------ .../zabbix/5.0/java-gateway/requirements.txt | 1 + .../advanced/zabbix/5.0/proxy-mysql/Makefile | 6 +- .../zabbix/5.0/proxy-mysql/kaniko-build.py | 196 ------------------ .../zabbix/5.0/proxy-mysql/requirements.txt | 1 + .../zabbix/5.0/proxy-sqlite3/Makefile | 6 +- .../zabbix/5.0/proxy-sqlite3/kaniko-build.py | 196 ------------------ .../zabbix/5.0/proxy-sqlite3/requirements.txt | 1 + .../advanced/zabbix/5.0/server-mysql/Makefile | 6 +- .../zabbix/5.0/server-mysql/kaniko-build.py | 196 ------------------ .../zabbix/5.0/server-mysql/requirements.txt | 1 + .../advanced/zabbix/5.0/server-pgsql/Makefile | 6 +- .../zabbix/5.0/server-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/5.0/server-pgsql/requirements.txt | 1 + linux/advanced/zabbix/5.0/snmptraps/Makefile | 6 +- .../zabbix/5.0/snmptraps/kaniko-build.py | 196 ------------------ .../zabbix/5.0/snmptraps/requirements.txt | 1 + linux/advanced/zabbix/5.0/web-mysql/Makefile | 6 +- .../zabbix/5.0/web-mysql/kaniko-build.py | 196 ------------------ .../zabbix/5.0/web-mysql/requirements.txt | 1 + linux/advanced/zabbix/5.0/web-pgsql/Makefile | 6 +- .../zabbix/5.0/web-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/5.0/web-pgsql/requirements.txt | 1 + linux/advanced/zabbix/5.2/agent/Makefile | 6 +- .../advanced/zabbix/5.2/agent/kaniko-build.py | 196 ------------------ .../zabbix/5.2/agent/requirements.txt | 1 + linux/advanced/zabbix/5.2/agent2/Makefile | 6 +- .../zabbix/5.2/agent2/kaniko-build.py | 196 ------------------ .../zabbix/5.2/agent2/requirements.txt | 1 + .../advanced/zabbix/5.2/java-gateway/Makefile | 6 +- .../zabbix/5.2/java-gateway/kaniko-build.py | 196 ------------------ .../zabbix/5.2/java-gateway/requirements.txt | 1 + .../advanced/zabbix/5.2/proxy-mysql/Makefile | 6 +- .../zabbix/5.2/proxy-mysql/kaniko-build.py | 196 ------------------ .../zabbix/5.2/proxy-mysql/requirements.txt | 1 + .../zabbix/5.2/proxy-sqlite3/Makefile | 6 +- .../zabbix/5.2/proxy-sqlite3/kaniko-build.py | 196 ------------------ .../zabbix/5.2/proxy-sqlite3/requirements.txt | 1 + .../advanced/zabbix/5.2/server-mysql/Makefile | 6 +- .../zabbix/5.2/server-mysql/kaniko-build.py | 196 ------------------ .../zabbix/5.2/server-mysql/requirements.txt | 1 + .../advanced/zabbix/5.2/server-pgsql/Makefile | 6 +- .../zabbix/5.2/server-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/5.2/server-pgsql/requirements.txt | 1 + linux/advanced/zabbix/5.2/snmptraps/Makefile | 6 +- .../zabbix/5.2/snmptraps/kaniko-build.py | 196 ------------------ .../zabbix/5.2/snmptraps/requirements.txt | 1 + linux/advanced/zabbix/5.2/web-mysql/Makefile | 6 +- .../zabbix/5.2/web-mysql/kaniko-build.py | 196 ------------------ .../zabbix/5.2/web-mysql/requirements.txt | 1 + linux/advanced/zabbix/5.2/web-pgsql/Makefile | 6 +- .../zabbix/5.2/web-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/5.2/web-pgsql/requirements.txt | 1 + linux/advanced/zabbix/5.4/agent/Makefile | 6 +- .../advanced/zabbix/5.4/agent/kaniko-build.py | 196 ------------------ .../zabbix/5.4/agent/requirements.txt | 1 + linux/advanced/zabbix/5.4/agent2/Makefile | 6 +- .../zabbix/5.4/agent2/kaniko-build.py | 196 ------------------ .../zabbix/5.4/agent2/requirements.txt | 1 + .../advanced/zabbix/5.4/java-gateway/Makefile | 6 +- .../zabbix/5.4/java-gateway/kaniko-build.py | 196 ------------------ .../zabbix/5.4/java-gateway/requirements.txt | 1 + .../advanced/zabbix/5.4/proxy-mysql/Makefile | 6 +- .../zabbix/5.4/proxy-mysql/kaniko-build.py | 196 ------------------ .../zabbix/5.4/proxy-mysql/requirements.txt | 1 + .../zabbix/5.4/proxy-sqlite3/Makefile | 6 +- .../zabbix/5.4/proxy-sqlite3/kaniko-build.py | 196 ------------------ .../zabbix/5.4/proxy-sqlite3/requirements.txt | 1 + .../advanced/zabbix/5.4/server-mysql/Makefile | 6 +- .../zabbix/5.4/server-mysql/kaniko-build.py | 196 ------------------ .../zabbix/5.4/server-mysql/requirements.txt | 1 + .../advanced/zabbix/5.4/server-pgsql/Makefile | 6 +- .../zabbix/5.4/server-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/5.4/server-pgsql/requirements.txt | 1 + linux/advanced/zabbix/5.4/snmptraps/Makefile | 6 +- .../zabbix/5.4/snmptraps/kaniko-build.py | 196 ------------------ .../zabbix/5.4/snmptraps/requirements.txt | 1 + linux/advanced/zabbix/5.4/web-mysql/Makefile | 6 +- .../zabbix/5.4/web-mysql/kaniko-build.py | 196 ------------------ .../zabbix/5.4/web-mysql/requirements.txt | 1 + linux/advanced/zabbix/5.4/web-pgsql/Makefile | 6 +- .../zabbix/5.4/web-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/5.4/web-pgsql/requirements.txt | 1 + linux/advanced/zabbix/6.0/agent/Makefile | 6 +- .../advanced/zabbix/6.0/agent/kaniko-build.py | 196 ------------------ .../zabbix/6.0/agent/requirements.txt | 1 + linux/advanced/zabbix/6.0/agent2/Makefile | 6 +- .../zabbix/6.0/agent2/kaniko-build.py | 196 ------------------ .../zabbix/6.0/agent2/requirements.txt | 1 + .../advanced/zabbix/6.0/java-gateway/Makefile | 6 +- .../zabbix/6.0/java-gateway/kaniko-build.py | 196 ------------------ .../zabbix/6.0/java-gateway/requirements.txt | 1 + .../advanced/zabbix/6.0/proxy-mysql/Makefile | 6 +- .../zabbix/6.0/proxy-mysql/kaniko-build.py | 196 ------------------ .../zabbix/6.0/proxy-mysql/requirements.txt | 1 + .../zabbix/6.0/proxy-sqlite3/Makefile | 6 +- .../zabbix/6.0/proxy-sqlite3/kaniko-build.py | 196 ------------------ .../zabbix/6.0/proxy-sqlite3/requirements.txt | 1 + .../advanced/zabbix/6.0/server-mysql/Makefile | 6 +- .../zabbix/6.0/server-mysql/kaniko-build.py | 196 ------------------ .../zabbix/6.0/server-mysql/requirements.txt | 1 + .../advanced/zabbix/6.0/server-pgsql/Makefile | 6 +- .../zabbix/6.0/server-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/6.0/server-pgsql/requirements.txt | 1 + linux/advanced/zabbix/6.0/snmptraps/Makefile | 6 +- .../zabbix/6.0/snmptraps/kaniko-build.py | 196 ------------------ .../zabbix/6.0/snmptraps/requirements.txt | 1 + linux/advanced/zabbix/6.0/web-mysql/Makefile | 6 +- .../zabbix/6.0/web-mysql/kaniko-build.py | 196 ------------------ .../zabbix/6.0/web-mysql/requirements.txt | 1 + linux/advanced/zabbix/6.0/web-pgsql/Makefile | 6 +- .../zabbix/6.0/web-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/6.0/web-pgsql/requirements.txt | 1 + linux/advanced/zabbix/6.2/agent/Makefile | 6 +- .../advanced/zabbix/6.2/agent/kaniko-build.py | 196 ------------------ .../zabbix/6.2/agent/requirements.txt | 1 + linux/advanced/zabbix/6.2/agent2/Makefile | 6 +- .../zabbix/6.2/agent2/kaniko-build.py | 196 ------------------ .../zabbix/6.2/agent2/requirements.txt | 1 + .../advanced/zabbix/6.2/java-gateway/Makefile | 6 +- .../zabbix/6.2/java-gateway/kaniko-build.py | 196 ------------------ .../zabbix/6.2/java-gateway/requirements.txt | 1 + .../advanced/zabbix/6.2/proxy-mysql/Makefile | 6 +- .../zabbix/6.2/proxy-mysql/kaniko-build.py | 196 ------------------ .../zabbix/6.2/proxy-mysql/requirements.txt | 1 + .../zabbix/6.2/proxy-sqlite3/Makefile | 6 +- .../zabbix/6.2/proxy-sqlite3/kaniko-build.py | 196 ------------------ .../zabbix/6.2/proxy-sqlite3/requirements.txt | 1 + .../advanced/zabbix/6.2/server-mysql/Makefile | 6 +- .../zabbix/6.2/server-mysql/kaniko-build.py | 196 ------------------ .../zabbix/6.2/server-mysql/requirements.txt | 1 + .../advanced/zabbix/6.2/server-pgsql/Makefile | 6 +- .../zabbix/6.2/server-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/6.2/server-pgsql/requirements.txt | 1 + linux/advanced/zabbix/6.2/snmptraps/Makefile | 6 +- .../zabbix/6.2/snmptraps/kaniko-build.py | 196 ------------------ .../zabbix/6.2/snmptraps/requirements.txt | 1 + linux/advanced/zabbix/6.2/web-mysql/Makefile | 6 +- .../zabbix/6.2/web-mysql/kaniko-build.py | 196 ------------------ .../zabbix/6.2/web-mysql/requirements.txt | 1 + linux/advanced/zabbix/6.2/web-pgsql/Makefile | 6 +- .../zabbix/6.2/web-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/6.2/web-pgsql/requirements.txt | 1 + linux/advanced/zabbix/6.4/agent/Makefile | 6 +- .../advanced/zabbix/6.4/agent/kaniko-build.py | 196 ------------------ .../zabbix/6.4/agent/requirements.txt | 1 + linux/advanced/zabbix/6.4/agent2/Makefile | 6 +- .../zabbix/6.4/agent2/kaniko-build.py | 196 ------------------ .../zabbix/6.4/agent2/requirements.txt | 1 + .../advanced/zabbix/6.4/java-gateway/Makefile | 6 +- .../zabbix/6.4/java-gateway/kaniko-build.py | 196 ------------------ .../zabbix/6.4/java-gateway/requirements.txt | 1 + .../advanced/zabbix/6.4/proxy-mysql/Makefile | 6 +- .../zabbix/6.4/proxy-mysql/kaniko-build.py | 196 ------------------ .../zabbix/6.4/proxy-mysql/requirements.txt | 1 + .../zabbix/6.4/proxy-sqlite3/Makefile | 6 +- .../zabbix/6.4/proxy-sqlite3/kaniko-build.py | 196 ------------------ .../zabbix/6.4/proxy-sqlite3/requirements.txt | 1 + .../advanced/zabbix/6.4/server-mysql/Makefile | 6 +- .../zabbix/6.4/server-mysql/kaniko-build.py | 196 ------------------ .../zabbix/6.4/server-mysql/requirements.txt | 1 + .../advanced/zabbix/6.4/server-pgsql/Makefile | 6 +- .../zabbix/6.4/server-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/6.4/server-pgsql/requirements.txt | 1 + linux/advanced/zabbix/6.4/snmptraps/Makefile | 6 +- .../zabbix/6.4/snmptraps/kaniko-build.py | 196 ------------------ .../zabbix/6.4/snmptraps/requirements.txt | 1 + linux/advanced/zabbix/6.4/web-mysql/Makefile | 6 +- .../zabbix/6.4/web-mysql/kaniko-build.py | 196 ------------------ .../zabbix/6.4/web-mysql/requirements.txt | 1 + linux/advanced/zabbix/6.4/web-pgsql/Makefile | 6 +- .../zabbix/6.4/web-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/6.4/web-pgsql/requirements.txt | 1 + linux/advanced/zabbix/latest/agent/Makefile | 6 +- .../zabbix/latest/agent/kaniko-build.py | 196 ------------------ .../zabbix/latest/agent/requirements.txt | 1 + linux/advanced/zabbix/latest/agent2/Makefile | 6 +- .../zabbix/latest/agent2/kaniko-build.py | 196 ------------------ .../zabbix/latest/agent2/requirements.txt | 1 + .../zabbix/latest/java-gateway/Makefile | 6 +- .../latest/java-gateway/kaniko-build.py | 196 ------------------ .../latest/java-gateway/requirements.txt | 1 + .../zabbix/latest/proxy-mysql/Makefile | 6 +- .../zabbix/latest/proxy-mysql/kaniko-build.py | 196 ------------------ .../latest/proxy-mysql/requirements.txt | 1 + .../zabbix/latest/proxy-sqlite3/Makefile | 6 +- .../latest/proxy-sqlite3/kaniko-build.py | 196 ------------------ .../latest/proxy-sqlite3/requirements.txt | 1 + .../zabbix/latest/server-mysql/Makefile | 6 +- .../latest/server-mysql/kaniko-build.py | 196 ------------------ .../latest/server-mysql/requirements.txt | 1 + .../zabbix/latest/server-pgsql/Makefile | 6 +- .../latest/server-pgsql/kaniko-build.py | 196 ------------------ .../latest/server-pgsql/requirements.txt | 1 + .../advanced/zabbix/latest/snmptraps/Makefile | 6 +- .../zabbix/latest/snmptraps/kaniko-build.py | 196 ------------------ .../zabbix/latest/snmptraps/requirements.txt | 1 + .../advanced/zabbix/latest/web-mysql/Makefile | 6 +- .../zabbix/latest/web-mysql/kaniko-build.py | 196 ------------------ .../zabbix/latest/web-mysql/requirements.txt | 1 + .../advanced/zabbix/latest/web-pgsql/Makefile | 6 +- .../zabbix/latest/web-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/latest/web-pgsql/requirements.txt | 1 + linux/advanced/zabbix/trunk/agent/Makefile | 6 +- .../zabbix/trunk/agent/kaniko-build.py | 196 ------------------ .../zabbix/trunk/agent/requirements.txt | 1 + linux/advanced/zabbix/trunk/agent2/Makefile | 6 +- .../zabbix/trunk/agent2/kaniko-build.py | 196 ------------------ .../zabbix/trunk/agent2/requirements.txt | 1 + .../zabbix/trunk/java-gateway/Makefile | 6 +- .../zabbix/trunk/java-gateway/kaniko-build.py | 196 ------------------ .../trunk/java-gateway/requirements.txt | 1 + .../zabbix/trunk/proxy-mysql/Makefile | 6 +- .../zabbix/trunk/proxy-mysql/kaniko-build.py | 196 ------------------ .../zabbix/trunk/proxy-mysql/requirements.txt | 1 + .../zabbix/trunk/proxy-sqlite3/Makefile | 6 +- .../trunk/proxy-sqlite3/kaniko-build.py | 196 ------------------ .../trunk/proxy-sqlite3/requirements.txt | 1 + .../zabbix/trunk/server-mysql/Makefile | 6 +- .../zabbix/trunk/server-mysql/kaniko-build.py | 196 ------------------ .../trunk/server-mysql/requirements.txt | 1 + .../zabbix/trunk/server-pgsql/Makefile | 6 +- .../zabbix/trunk/server-pgsql/kaniko-build.py | 196 ------------------ .../trunk/server-pgsql/requirements.txt | 1 + .../advanced/zabbix/trunk/snmptraps/Makefile | 6 +- .../zabbix/trunk/snmptraps/kaniko-build.py | 196 ------------------ .../zabbix/trunk/snmptraps/requirements.txt | 1 + .../advanced/zabbix/trunk/web-mysql/Makefile | 6 +- .../zabbix/trunk/web-mysql/kaniko-build.py | 196 ------------------ .../zabbix/trunk/web-mysql/requirements.txt | 1 + .../advanced/zabbix/trunk/web-pgsql/Makefile | 6 +- .../zabbix/trunk/web-pgsql/kaniko-build.py | 196 ------------------ .../zabbix/trunk/web-pgsql/requirements.txt | 1 + .../ecosystem/epicmorg/devel/jdk11/Makefile | 6 +- .../epicmorg/devel/jdk11/kaniko-build.py | 196 ------------------ .../epicmorg/devel/jdk11/requirements.txt | 1 + .../ecosystem/epicmorg/devel/jdk16/Makefile | 6 +- .../epicmorg/devel/jdk16/kaniko-build.py | 196 ------------------ .../epicmorg/devel/jdk16/requirements.txt | 1 + .../ecosystem/epicmorg/devel/jdk6/Makefile | 6 +- .../epicmorg/devel/jdk6/kaniko-build.py | 196 ------------------ .../epicmorg/devel/jdk6/requirements.txt | 1 + .../ecosystem/epicmorg/devel/jdk7/Makefile | 6 +- .../epicmorg/devel/jdk7/kaniko-build.py | 196 ------------------ .../epicmorg/devel/jdk7/requirements.txt | 1 + .../ecosystem/epicmorg/devel/jdk8/Makefile | 6 +- .../epicmorg/devel/jdk8/kaniko-build.py | 196 ------------------ .../epicmorg/devel/jdk8/requirements.txt | 1 + .../ecosystem/epicmorg/devel/main/Makefile | 6 +- .../epicmorg/devel/main/kaniko-build.py | 196 ------------------ .../epicmorg/devel/main/requirements.txt | 1 + .../ecosystem/epicmorg/edge/jdk11/Makefile | 6 +- .../epicmorg/edge/jdk11/kaniko-build.py | 196 ------------------ .../epicmorg/edge/jdk11/requirements.txt | 1 + .../ecosystem/epicmorg/edge/jdk16/Makefile | 6 +- .../epicmorg/edge/jdk16/kaniko-build.py | 196 ------------------ .../epicmorg/edge/jdk16/requirements.txt | 1 + .../ecosystem/epicmorg/edge/jdk6/Makefile | 6 +- .../epicmorg/edge/jdk6/kaniko-build.py | 196 ------------------ .../epicmorg/edge/jdk6/requirements.txt | 1 + .../ecosystem/epicmorg/edge/jdk7/Makefile | 6 +- .../epicmorg/edge/jdk7/kaniko-build.py | 196 ------------------ .../epicmorg/edge/jdk7/requirements.txt | 1 + .../ecosystem/epicmorg/edge/jdk8/Makefile | 6 +- .../epicmorg/edge/jdk8/kaniko-build.py | 196 ------------------ .../epicmorg/edge/jdk8/requirements.txt | 1 + .../ecosystem/epicmorg/edge/main/Makefile | 6 +- .../epicmorg/edge/main/kaniko-build.py | 196 ------------------ .../epicmorg/edge/main/requirements.txt | 1 + .../ecosystem/epicmorg/prod/jdk11/Makefile | 6 +- .../epicmorg/prod/jdk11/kaniko-build.py | 196 ------------------ .../epicmorg/prod/jdk11/requirements.txt | 1 + .../ecosystem/epicmorg/prod/jdk16/Makefile | 6 +- .../epicmorg/prod/jdk16/kaniko-build.py | 196 ------------------ .../epicmorg/prod/jdk16/requirements.txt | 1 + .../ecosystem/epicmorg/prod/jdk6/Makefile | 6 +- .../epicmorg/prod/jdk6/kaniko-build.py | 196 ------------------ .../epicmorg/prod/jdk6/requirements.txt | 1 + .../ecosystem/epicmorg/prod/jdk7/Makefile | 6 +- .../epicmorg/prod/jdk7/kaniko-build.py | 196 ------------------ .../epicmorg/prod/jdk7/requirements.txt | 1 + .../ecosystem/epicmorg/prod/jdk8/Makefile | 6 +- .../epicmorg/prod/jdk8/kaniko-build.py | 196 ------------------ .../epicmorg/prod/jdk8/requirements.txt | 1 + .../ecosystem/epicmorg/prod/main/Makefile | 6 +- .../epicmorg/prod/main/kaniko-build.py | 196 ------------------ .../epicmorg/prod/main/requirements.txt | 1 + .../ecosystem/freegpt-webui/1.0/Makefile | 6 +- .../freegpt-webui/1.0/kaniko-build.py | 196 ------------------ .../freegpt-webui/1.0/requirements.txt | 1 + .../ecosystem/freegpt-webui/1.1/Makefile | 6 +- .../freegpt-webui/1.1/kaniko-build.py | 196 ------------------ .../freegpt-webui/1.1/requirements.txt | 1 + .../ecosystem/freegpt-webui/1.2/Makefile | 6 +- .../freegpt-webui/1.2/kaniko-build.py | 196 ------------------ .../freegpt-webui/1.2/requirements.txt | 1 + .../ecosystem/freegpt-webui/1.3.1/Makefile | 6 +- .../freegpt-webui/1.3.1/kaniko-build.py | 196 ------------------ .../freegpt-webui/1.3.1/requirements.txt | 1 + .../ecosystem/freegpt-webui/1.3.2/Makefile | 6 +- .../freegpt-webui/1.3.2/kaniko-build.py | 196 ------------------ .../freegpt-webui/1.3.2/requirements.txt | 1 + .../ecosystem/freegpt-webui/1.3/Makefile | 6 +- .../freegpt-webui/1.3/kaniko-build.py | 196 ------------------ .../freegpt-webui/1.3/requirements.txt | 1 + .../ecosystem/freegpt-webui/1.4/Makefile | 6 +- .../freegpt-webui/1.4/kaniko-build.py | 196 ------------------ .../freegpt-webui/1.4/requirements.txt | 1 + .../ecosystem/freegpt-webui/latest/Makefile | 6 +- .../freegpt-webui/latest/kaniko-build.py | 196 ------------------ .../freegpt-webui/latest/requirements.txt | 1 + .../ecosystem/syspass/sysPass/kaniko-build.py | 196 ------------------ .../syspass/sysPass/requirements.txt | 1 + linux/ecosystem/apache2/php5.5/Makefile | 6 +- .../ecosystem/apache2/php5.5/kaniko-build.py | 196 ------------------ .../ecosystem/apache2/php5.5/requirements.txt | 1 + linux/ecosystem/apache2/php7.0/Makefile | 6 +- .../ecosystem/apache2/php7.0/kaniko-build.py | 196 ------------------ .../ecosystem/apache2/php7.0/requirements.txt | 1 + linux/ecosystem/apache2/php7.1/Makefile | 6 +- .../ecosystem/apache2/php7.1/kaniko-build.py | 196 ------------------ .../ecosystem/apache2/php7.1/requirements.txt | 1 + linux/ecosystem/apache2/php7.2/Makefile | 6 +- .../ecosystem/apache2/php7.2/kaniko-build.py | 196 ------------------ .../ecosystem/apache2/php7.2/requirements.txt | 1 + linux/ecosystem/apache2/php7.3/Makefile | 6 +- .../ecosystem/apache2/php7.3/kaniko-build.py | 196 ------------------ .../ecosystem/apache2/php7.3/requirements.txt | 1 + linux/ecosystem/apache2/php7.4/Makefile | 6 +- .../ecosystem/apache2/php7.4/kaniko-build.py | 196 ------------------ .../ecosystem/apache2/php7.4/requirements.txt | 1 + linux/ecosystem/apache2/php8.0/Makefile | 6 +- .../ecosystem/apache2/php8.0/kaniko-build.py | 196 ------------------ .../ecosystem/apache2/php8.0/requirements.txt | 1 + linux/ecosystem/apache2/php8.1/Makefile | 6 +- .../ecosystem/apache2/php8.1/kaniko-build.py | 196 ------------------ .../ecosystem/apache2/php8.1/requirements.txt | 1 + linux/ecosystem/apache2/php8.2/Makefile | 6 +- .../ecosystem/apache2/php8.2/kaniko-build.py | 196 ------------------ .../ecosystem/apache2/php8.2/requirements.txt | 1 + linux/ecosystem/apache2/php8.3/Makefile | 6 +- .../ecosystem/apache2/php8.3/kaniko-build.py | 196 ------------------ .../ecosystem/apache2/php8.3/requirements.txt | 1 + .../atlassian/bitbucket/1/1.0.3/Makefile | 6 +- .../bitbucket/1/1.0.3/kaniko-build.py | 196 ------------------ .../bitbucket/1/1.0.3/requirements.txt | 1 + .../atlassian/bitbucket/1/1.1.2/Makefile | 6 +- .../bitbucket/1/1.1.2/kaniko-build.py | 196 ------------------ .../bitbucket/1/1.1.2/requirements.txt | 1 + .../atlassian/bitbucket/1/1.2.1/Makefile | 6 +- .../bitbucket/1/1.2.1/kaniko-build.py | 196 ------------------ .../bitbucket/1/1.2.1/requirements.txt | 1 + .../atlassian/bitbucket/1/1.2.4/Makefile | 6 +- .../bitbucket/1/1.2.4/kaniko-build.py | 196 ------------------ .../bitbucket/1/1.2.4/requirements.txt | 1 + .../atlassian/bitbucket/1/1.3.1/Makefile | 6 +- .../bitbucket/1/1.3.1/kaniko-build.py | 196 ------------------ .../bitbucket/1/1.3.1/requirements.txt | 1 + .../atlassian/bitbucket/2/2.0.3/Makefile | 6 +- .../bitbucket/2/2.0.3/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.0.3/requirements.txt | 1 + .../atlassian/bitbucket/2/2.1.2/Makefile | 6 +- .../bitbucket/2/2.1.2/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.1.2/requirements.txt | 1 + .../atlassian/bitbucket/2/2.10.0/Makefile | 6 +- .../bitbucket/2/2.10.0/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.10.0/requirements.txt | 1 + .../atlassian/bitbucket/2/2.10.1/Makefile | 6 +- .../bitbucket/2/2.10.1/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.10.1/requirements.txt | 1 + .../atlassian/bitbucket/2/2.10.2/Makefile | 6 +- .../bitbucket/2/2.10.2/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.10.2/requirements.txt | 1 + .../atlassian/bitbucket/2/2.10.3/Makefile | 6 +- .../bitbucket/2/2.10.3/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.10.3/requirements.txt | 1 + .../atlassian/bitbucket/2/2.10.4/Makefile | 6 +- .../bitbucket/2/2.10.4/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.10.4/requirements.txt | 1 + .../atlassian/bitbucket/2/2.10.5/Makefile | 6 +- .../bitbucket/2/2.10.5/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.10.5/requirements.txt | 1 + .../atlassian/bitbucket/2/2.11.3/Makefile | 6 +- .../bitbucket/2/2.11.3/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.11.3/requirements.txt | 1 + .../atlassian/bitbucket/2/2.11.4/Makefile | 6 +- .../bitbucket/2/2.11.4/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.11.4/requirements.txt | 1 + .../atlassian/bitbucket/2/2.11.5/Makefile | 6 +- .../bitbucket/2/2.11.5/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.11.5/requirements.txt | 1 + .../atlassian/bitbucket/2/2.11.6/Makefile | 6 +- .../bitbucket/2/2.11.6/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.11.6/requirements.txt | 1 + .../atlassian/bitbucket/2/2.11.7/Makefile | 6 +- .../bitbucket/2/2.11.7/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.11.7/requirements.txt | 1 + .../atlassian/bitbucket/2/2.11.8/Makefile | 6 +- .../bitbucket/2/2.11.8/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.11.8/requirements.txt | 1 + .../atlassian/bitbucket/2/2.11.9/Makefile | 6 +- .../bitbucket/2/2.11.9/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.11.9/requirements.txt | 1 + .../atlassian/bitbucket/2/2.12.0/Makefile | 6 +- .../bitbucket/2/2.12.0/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.12.0/requirements.txt | 1 + .../atlassian/bitbucket/2/2.12.1/Makefile | 6 +- .../bitbucket/2/2.12.1/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.12.1/requirements.txt | 1 + .../atlassian/bitbucket/2/2.12.2/Makefile | 6 +- .../bitbucket/2/2.12.2/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.12.2/requirements.txt | 1 + .../atlassian/bitbucket/2/2.12.3/Makefile | 6 +- .../bitbucket/2/2.12.3/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.12.3/requirements.txt | 1 + .../atlassian/bitbucket/2/2.12.4/Makefile | 6 +- .../bitbucket/2/2.12.4/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.12.4/requirements.txt | 1 + .../atlassian/bitbucket/2/2.12.5/Makefile | 6 +- .../bitbucket/2/2.12.5/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.12.5/requirements.txt | 1 + .../atlassian/bitbucket/2/2.12.6/Makefile | 6 +- .../bitbucket/2/2.12.6/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.12.6/requirements.txt | 1 + .../atlassian/bitbucket/2/2.2.0/Makefile | 6 +- .../bitbucket/2/2.2.0/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.2.0/requirements.txt | 1 + .../atlassian/bitbucket/2/2.3.1/Makefile | 6 +- .../bitbucket/2/2.3.1/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.3.1/requirements.txt | 1 + .../atlassian/bitbucket/2/2.4.2/Makefile | 6 +- .../bitbucket/2/2.4.2/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.4.2/requirements.txt | 1 + .../atlassian/bitbucket/2/2.5.4/Makefile | 6 +- .../bitbucket/2/2.5.4/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.5.4/requirements.txt | 1 + .../atlassian/bitbucket/2/2.6.5/Makefile | 6 +- .../bitbucket/2/2.6.5/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.6.5/requirements.txt | 1 + .../atlassian/bitbucket/2/2.7.6/Makefile | 6 +- .../bitbucket/2/2.7.6/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.7.6/requirements.txt | 1 + .../atlassian/bitbucket/2/2.8.4/Makefile | 6 +- .../bitbucket/2/2.8.4/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.8.4/requirements.txt | 1 + .../atlassian/bitbucket/2/2.8.5/Makefile | 6 +- .../bitbucket/2/2.8.5/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.8.5/requirements.txt | 1 + .../atlassian/bitbucket/2/2.9.1/Makefile | 6 +- .../bitbucket/2/2.9.1/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.9.1/requirements.txt | 1 + .../atlassian/bitbucket/2/2.9.2/Makefile | 6 +- .../bitbucket/2/2.9.2/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.9.2/requirements.txt | 1 + .../atlassian/bitbucket/2/2.9.3/Makefile | 6 +- .../bitbucket/2/2.9.3/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.9.3/requirements.txt | 1 + .../atlassian/bitbucket/2/2.9.4/Makefile | 6 +- .../bitbucket/2/2.9.4/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.9.4/requirements.txt | 1 + .../atlassian/bitbucket/2/2.9.5/Makefile | 6 +- .../bitbucket/2/2.9.5/kaniko-build.py | 196 ------------------ .../bitbucket/2/2.9.5/requirements.txt | 1 + .../atlassian/bitbucket/3/3.0.1/Makefile | 6 +- .../bitbucket/3/3.0.1/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.0.1/requirements.txt | 1 + .../atlassian/bitbucket/3/3.0.4/Makefile | 6 +- .../bitbucket/3/3.0.4/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.0.4/requirements.txt | 1 + .../atlassian/bitbucket/3/3.0.5/Makefile | 6 +- .../bitbucket/3/3.0.5/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.0.5/requirements.txt | 1 + .../atlassian/bitbucket/3/3.0.6/Makefile | 6 +- .../bitbucket/3/3.0.6/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.0.6/requirements.txt | 1 + .../atlassian/bitbucket/3/3.0.7/Makefile | 6 +- .../bitbucket/3/3.0.7/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.0.7/requirements.txt | 1 + .../atlassian/bitbucket/3/3.0.8/Makefile | 6 +- .../bitbucket/3/3.0.8/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.0.8/requirements.txt | 1 + .../atlassian/bitbucket/3/3.1.0/Makefile | 6 +- .../bitbucket/3/3.1.0/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.1.0/requirements.txt | 1 + .../atlassian/bitbucket/3/3.1.1/Makefile | 6 +- .../bitbucket/3/3.1.1/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.1.1/requirements.txt | 1 + .../atlassian/bitbucket/3/3.1.3/Makefile | 6 +- .../bitbucket/3/3.1.3/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.1.3/requirements.txt | 1 + .../atlassian/bitbucket/3/3.1.4/Makefile | 6 +- .../bitbucket/3/3.1.4/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.1.4/requirements.txt | 1 + .../atlassian/bitbucket/3/3.1.5/Makefile | 6 +- .../bitbucket/3/3.1.5/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.1.5/requirements.txt | 1 + .../atlassian/bitbucket/3/3.1.7/Makefile | 6 +- .../bitbucket/3/3.1.7/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.1.7/requirements.txt | 1 + .../atlassian/bitbucket/3/3.10.0/Makefile | 6 +- .../bitbucket/3/3.10.0/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.10.0/requirements.txt | 1 + .../atlassian/bitbucket/3/3.10.2/Makefile | 6 +- .../bitbucket/3/3.10.2/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.10.2/requirements.txt | 1 + .../atlassian/bitbucket/3/3.10.3/Makefile | 6 +- .../bitbucket/3/3.10.3/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.10.3/requirements.txt | 1 + .../atlassian/bitbucket/3/3.10.4/Makefile | 6 +- .../bitbucket/3/3.10.4/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.10.4/requirements.txt | 1 + .../atlassian/bitbucket/3/3.11.0/Makefile | 6 +- .../bitbucket/3/3.11.0/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.11.0/requirements.txt | 1 + .../atlassian/bitbucket/3/3.11.1/Makefile | 6 +- .../bitbucket/3/3.11.1/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.11.1/requirements.txt | 1 + .../atlassian/bitbucket/3/3.11.2/Makefile | 6 +- .../bitbucket/3/3.11.2/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.11.2/requirements.txt | 1 + .../atlassian/bitbucket/3/3.11.3/Makefile | 6 +- .../bitbucket/3/3.11.3/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.11.3/requirements.txt | 1 + .../atlassian/bitbucket/3/3.11.4/Makefile | 6 +- .../bitbucket/3/3.11.4/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.11.4/requirements.txt | 1 + .../atlassian/bitbucket/3/3.11.6/Makefile | 6 +- .../bitbucket/3/3.11.6/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.11.6/requirements.txt | 1 + .../atlassian/bitbucket/3/3.2.0/Makefile | 6 +- .../bitbucket/3/3.2.0/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.2.0/requirements.txt | 1 + .../atlassian/bitbucket/3/3.2.2/Makefile | 6 +- .../bitbucket/3/3.2.2/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.2.2/requirements.txt | 1 + .../atlassian/bitbucket/3/3.2.4/Makefile | 6 +- .../bitbucket/3/3.2.4/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.2.4/requirements.txt | 1 + .../atlassian/bitbucket/3/3.2.5/Makefile | 6 +- .../bitbucket/3/3.2.5/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.2.5/requirements.txt | 1 + .../atlassian/bitbucket/3/3.2.7/Makefile | 6 +- .../bitbucket/3/3.2.7/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.2.7/requirements.txt | 1 + .../atlassian/bitbucket/3/3.3.0/Makefile | 6 +- .../bitbucket/3/3.3.0/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.3.0/requirements.txt | 1 + .../atlassian/bitbucket/3/3.3.1/Makefile | 6 +- .../bitbucket/3/3.3.1/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.3.1/requirements.txt | 1 + .../atlassian/bitbucket/3/3.3.2/Makefile | 6 +- .../bitbucket/3/3.3.2/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.3.2/requirements.txt | 1 + .../atlassian/bitbucket/3/3.3.3/Makefile | 6 +- .../bitbucket/3/3.3.3/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.3.3/requirements.txt | 1 + .../atlassian/bitbucket/3/3.3.5/Makefile | 6 +- .../bitbucket/3/3.3.5/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.3.5/requirements.txt | 1 + .../atlassian/bitbucket/3/3.4.0/Makefile | 6 +- .../bitbucket/3/3.4.0/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.4.0/requirements.txt | 1 + .../atlassian/bitbucket/3/3.4.1/Makefile | 6 +- .../bitbucket/3/3.4.1/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.4.1/requirements.txt | 1 + .../atlassian/bitbucket/3/3.4.3/Makefile | 6 +- .../bitbucket/3/3.4.3/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.4.3/requirements.txt | 1 + .../atlassian/bitbucket/3/3.4.5/Makefile | 6 +- .../bitbucket/3/3.4.5/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.4.5/requirements.txt | 1 + .../atlassian/bitbucket/3/3.5.0/Makefile | 6 +- .../bitbucket/3/3.5.0/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.5.0/requirements.txt | 1 + .../atlassian/bitbucket/3/3.5.1/Makefile | 6 +- .../bitbucket/3/3.5.1/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.5.1/requirements.txt | 1 + .../atlassian/bitbucket/3/3.6.0/Makefile | 6 +- .../bitbucket/3/3.6.0/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.6.0/requirements.txt | 1 + .../atlassian/bitbucket/3/3.6.1/Makefile | 6 +- .../bitbucket/3/3.6.1/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.6.1/requirements.txt | 1 + .../atlassian/bitbucket/3/3.7.0/Makefile | 6 +- .../bitbucket/3/3.7.0/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.7.0/requirements.txt | 1 + .../atlassian/bitbucket/3/3.7.1/Makefile | 6 +- .../bitbucket/3/3.7.1/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.7.1/requirements.txt | 1 + .../atlassian/bitbucket/3/3.7.2/Makefile | 6 +- .../bitbucket/3/3.7.2/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.7.2/requirements.txt | 1 + .../atlassian/bitbucket/3/3.7.3/Makefile | 6 +- .../bitbucket/3/3.7.3/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.7.3/requirements.txt | 1 + .../atlassian/bitbucket/3/3.7.4/Makefile | 6 +- .../bitbucket/3/3.7.4/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.7.4/requirements.txt | 1 + .../atlassian/bitbucket/3/3.8.0/Makefile | 6 +- .../bitbucket/3/3.8.0/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.8.0/requirements.txt | 1 + .../atlassian/bitbucket/3/3.8.1/Makefile | 6 +- .../bitbucket/3/3.8.1/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.8.1/requirements.txt | 1 + .../atlassian/bitbucket/3/3.9.1/Makefile | 6 +- .../bitbucket/3/3.9.1/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.9.1/requirements.txt | 1 + .../atlassian/bitbucket/3/3.9.2/Makefile | 6 +- .../bitbucket/3/3.9.2/kaniko-build.py | 196 ------------------ .../bitbucket/3/3.9.2/requirements.txt | 1 + .../atlassian/bitbucket/4/4.0.1/Makefile | 6 +- .../bitbucket/4/4.0.1/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.0.1/requirements.txt | 1 + .../atlassian/bitbucket/4/4.0.2/Makefile | 6 +- .../bitbucket/4/4.0.2/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.0.2/requirements.txt | 1 + .../atlassian/bitbucket/4/4.0.3/Makefile | 6 +- .../bitbucket/4/4.0.3/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.0.3/requirements.txt | 1 + .../atlassian/bitbucket/4/4.0.4/Makefile | 6 +- .../bitbucket/4/4.0.4/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.0.4/requirements.txt | 1 + .../atlassian/bitbucket/4/4.0.6/Makefile | 6 +- .../bitbucket/4/4.0.6/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.0.6/requirements.txt | 1 + .../atlassian/bitbucket/4/4.0.7/Makefile | 6 +- .../bitbucket/4/4.0.7/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.0.7/requirements.txt | 1 + .../atlassian/bitbucket/4/4.0.8/Makefile | 6 +- .../bitbucket/4/4.0.8/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.0.8/requirements.txt | 1 + .../atlassian/bitbucket/4/4.1.0/Makefile | 6 +- .../bitbucket/4/4.1.0/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.1.0/requirements.txt | 1 + .../atlassian/bitbucket/4/4.1.3/Makefile | 6 +- .../bitbucket/4/4.1.3/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.1.3/requirements.txt | 1 + .../atlassian/bitbucket/4/4.1.4/Makefile | 6 +- .../bitbucket/4/4.1.4/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.1.4/requirements.txt | 1 + .../atlassian/bitbucket/4/4.1.6/Makefile | 6 +- .../bitbucket/4/4.1.6/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.1.6/requirements.txt | 1 + .../atlassian/bitbucket/4/4.10.0/Makefile | 6 +- .../bitbucket/4/4.10.0/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.10.0/requirements.txt | 1 + .../atlassian/bitbucket/4/4.10.1/Makefile | 6 +- .../bitbucket/4/4.10.1/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.10.1/requirements.txt | 1 + .../atlassian/bitbucket/4/4.10.2/Makefile | 6 +- .../bitbucket/4/4.10.2/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.10.2/requirements.txt | 1 + .../atlassian/bitbucket/4/4.11.1/Makefile | 6 +- .../bitbucket/4/4.11.1/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.11.1/requirements.txt | 1 + .../atlassian/bitbucket/4/4.11.2/Makefile | 6 +- .../bitbucket/4/4.11.2/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.11.2/requirements.txt | 1 + .../atlassian/bitbucket/4/4.12.0/Makefile | 6 +- .../bitbucket/4/4.12.0/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.12.0/requirements.txt | 1 + .../atlassian/bitbucket/4/4.12.1/Makefile | 6 +- .../bitbucket/4/4.12.1/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.12.1/requirements.txt | 1 + .../atlassian/bitbucket/4/4.13.0/Makefile | 6 +- .../bitbucket/4/4.13.0/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.13.0/requirements.txt | 1 + .../atlassian/bitbucket/4/4.13.1/Makefile | 6 +- .../bitbucket/4/4.13.1/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.13.1/requirements.txt | 1 + .../atlassian/bitbucket/4/4.14.0/Makefile | 6 +- .../bitbucket/4/4.14.0/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.14.0/requirements.txt | 1 + .../atlassian/bitbucket/4/4.14.1/Makefile | 6 +- .../bitbucket/4/4.14.1/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.14.1/requirements.txt | 1 + .../atlassian/bitbucket/4/4.14.10/Makefile | 6 +- .../bitbucket/4/4.14.10/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.14.10/requirements.txt | 1 + .../atlassian/bitbucket/4/4.14.11/Makefile | 6 +- .../bitbucket/4/4.14.11/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.14.11/requirements.txt | 1 + .../atlassian/bitbucket/4/4.14.12/Makefile | 6 +- .../bitbucket/4/4.14.12/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.14.12/requirements.txt | 1 + .../atlassian/bitbucket/4/4.14.2/Makefile | 6 +- .../bitbucket/4/4.14.2/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.14.2/requirements.txt | 1 + .../atlassian/bitbucket/4/4.14.3/Makefile | 6 +- .../bitbucket/4/4.14.3/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.14.3/requirements.txt | 1 + .../atlassian/bitbucket/4/4.14.4/Makefile | 6 +- .../bitbucket/4/4.14.4/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.14.4/requirements.txt | 1 + .../atlassian/bitbucket/4/4.14.5/Makefile | 6 +- .../bitbucket/4/4.14.5/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.14.5/requirements.txt | 1 + .../atlassian/bitbucket/4/4.14.6/Makefile | 6 +- .../bitbucket/4/4.14.6/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.14.6/requirements.txt | 1 + .../atlassian/bitbucket/4/4.14.7/Makefile | 6 +- .../bitbucket/4/4.14.7/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.14.7/requirements.txt | 1 + .../atlassian/bitbucket/4/4.14.8/Makefile | 6 +- .../bitbucket/4/4.14.8/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.14.8/requirements.txt | 1 + .../atlassian/bitbucket/4/4.14.9/Makefile | 6 +- .../bitbucket/4/4.14.9/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.14.9/requirements.txt | 1 + .../atlassian/bitbucket/4/4.2.0/Makefile | 6 +- .../bitbucket/4/4.2.0/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.2.0/requirements.txt | 1 + .../atlassian/bitbucket/4/4.2.1/Makefile | 6 +- .../bitbucket/4/4.2.1/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.2.1/requirements.txt | 1 + .../atlassian/bitbucket/4/4.2.2/Makefile | 6 +- .../bitbucket/4/4.2.2/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.2.2/requirements.txt | 1 + .../atlassian/bitbucket/4/4.2.3/Makefile | 6 +- .../bitbucket/4/4.2.3/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.2.3/requirements.txt | 1 + .../atlassian/bitbucket/4/4.3.0/Makefile | 6 +- .../bitbucket/4/4.3.0/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.3.0/requirements.txt | 1 + .../atlassian/bitbucket/4/4.3.1/Makefile | 6 +- .../bitbucket/4/4.3.1/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.3.1/requirements.txt | 1 + .../atlassian/bitbucket/4/4.3.2/Makefile | 6 +- .../bitbucket/4/4.3.2/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.3.2/requirements.txt | 1 + .../atlassian/bitbucket/4/4.3.3/Makefile | 6 +- .../bitbucket/4/4.3.3/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.3.3/requirements.txt | 1 + .../atlassian/bitbucket/4/4.4.0/Makefile | 6 +- .../bitbucket/4/4.4.0/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.4.0/requirements.txt | 1 + .../atlassian/bitbucket/4/4.4.1/Makefile | 6 +- .../bitbucket/4/4.4.1/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.4.1/requirements.txt | 1 + .../atlassian/bitbucket/4/4.4.2/Makefile | 6 +- .../bitbucket/4/4.4.2/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.4.2/requirements.txt | 1 + .../atlassian/bitbucket/4/4.4.4/Makefile | 6 +- .../bitbucket/4/4.4.4/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.4.4/requirements.txt | 1 + .../atlassian/bitbucket/4/4.5.1/Makefile | 6 +- .../bitbucket/4/4.5.1/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.5.1/requirements.txt | 1 + .../atlassian/bitbucket/4/4.5.2/Makefile | 6 +- .../bitbucket/4/4.5.2/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.5.2/requirements.txt | 1 + .../atlassian/bitbucket/4/4.5.3/Makefile | 6 +- .../bitbucket/4/4.5.3/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.5.3/requirements.txt | 1 + .../atlassian/bitbucket/4/4.6.0/Makefile | 6 +- .../bitbucket/4/4.6.0/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.6.0/requirements.txt | 1 + .../atlassian/bitbucket/4/4.6.1/Makefile | 6 +- .../bitbucket/4/4.6.1/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.6.1/requirements.txt | 1 + .../atlassian/bitbucket/4/4.6.2/Makefile | 6 +- .../bitbucket/4/4.6.2/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.6.2/requirements.txt | 1 + .../atlassian/bitbucket/4/4.6.3/Makefile | 6 +- .../bitbucket/4/4.6.3/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.6.3/requirements.txt | 1 + .../atlassian/bitbucket/4/4.6.4/Makefile | 6 +- .../bitbucket/4/4.6.4/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.6.4/requirements.txt | 1 + .../atlassian/bitbucket/4/4.7.1/Makefile | 6 +- .../bitbucket/4/4.7.1/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.7.1/requirements.txt | 1 + .../atlassian/bitbucket/4/4.7.2/Makefile | 6 +- .../bitbucket/4/4.7.2/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.7.2/requirements.txt | 1 + .../atlassian/bitbucket/4/4.8.0/Makefile | 6 +- .../bitbucket/4/4.8.0/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.8.0/requirements.txt | 1 + .../atlassian/bitbucket/4/4.8.1/Makefile | 6 +- .../bitbucket/4/4.8.1/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.8.1/requirements.txt | 1 + .../atlassian/bitbucket/4/4.8.2/Makefile | 6 +- .../bitbucket/4/4.8.2/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.8.2/requirements.txt | 1 + .../atlassian/bitbucket/4/4.8.3/Makefile | 6 +- .../bitbucket/4/4.8.3/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.8.3/requirements.txt | 1 + .../atlassian/bitbucket/4/4.8.4/Makefile | 6 +- .../bitbucket/4/4.8.4/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.8.4/requirements.txt | 1 + .../atlassian/bitbucket/4/4.8.5/Makefile | 6 +- .../bitbucket/4/4.8.5/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.8.5/requirements.txt | 1 + .../atlassian/bitbucket/4/4.8.6/Makefile | 6 +- .../bitbucket/4/4.8.6/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.8.6/requirements.txt | 1 + .../atlassian/bitbucket/4/4.9.0/Makefile | 6 +- .../bitbucket/4/4.9.0/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.9.0/requirements.txt | 1 + .../atlassian/bitbucket/4/4.9.1/Makefile | 6 +- .../bitbucket/4/4.9.1/kaniko-build.py | 196 ------------------ .../bitbucket/4/4.9.1/requirements.txt | 1 + .../atlassian/bitbucket/7/7.21.4/Makefile | 6 +- .../bitbucket/7/7.21.4/kaniko-build.py | 196 ------------------ .../bitbucket/7/7.21.4/requirements.txt | 1 + .../atlassian/bitbucket/8/8.0.0/Makefile | 6 +- .../bitbucket/8/8.0.0/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.0.0/requirements.txt | 1 + .../atlassian/bitbucket/8/8.0.3/Makefile | 6 +- .../bitbucket/8/8.0.3/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.0.3/requirements.txt | 1 + .../atlassian/bitbucket/8/8.1.0/Makefile | 6 +- .../bitbucket/8/8.1.0/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.1.0/requirements.txt | 1 + .../atlassian/bitbucket/8/8.1.3/Makefile | 6 +- .../bitbucket/8/8.1.3/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.1.3/requirements.txt | 1 + .../atlassian/bitbucket/8/8.12.0/Makefile | 6 +- .../bitbucket/8/8.12.0/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.12.0/requirements.txt | 1 + .../atlassian/bitbucket/8/8.17.0/Makefile | 6 +- .../bitbucket/8/8.17.0/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.17.0/requirements.txt | 1 + .../atlassian/bitbucket/8/8.19.6/Makefile | 6 +- .../bitbucket/8/8.19.6/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.19.6/requirements.txt | 1 + .../atlassian/bitbucket/8/8.2.0/Makefile | 6 +- .../bitbucket/8/8.2.0/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.2.0/requirements.txt | 1 + .../atlassian/bitbucket/8/8.2.2/Makefile | 6 +- .../bitbucket/8/8.2.2/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.2.2/requirements.txt | 1 + .../atlassian/bitbucket/8/8.3.0/Makefile | 6 +- .../bitbucket/8/8.3.0/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.3.0/requirements.txt | 1 + .../atlassian/bitbucket/8/8.3.1/Makefile | 6 +- .../bitbucket/8/8.3.1/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.3.1/requirements.txt | 1 + .../atlassian/bitbucket/8/8.3.2/Makefile | 6 +- .../bitbucket/8/8.3.2/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.3.2/requirements.txt | 1 + .../atlassian/bitbucket/8/8.3.3/Makefile | 6 +- .../bitbucket/8/8.3.3/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.3.3/requirements.txt | 1 + .../atlassian/bitbucket/8/8.4.0/Makefile | 6 +- .../bitbucket/8/8.4.0/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.4.0/requirements.txt | 1 + .../atlassian/bitbucket/8/8.4.1/Makefile | 6 +- .../bitbucket/8/8.4.1/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.4.1/requirements.txt | 1 + .../atlassian/bitbucket/8/8.4.2/Makefile | 6 +- .../bitbucket/8/8.4.2/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.4.2/requirements.txt | 1 + .../atlassian/bitbucket/8/8.5.0/Makefile | 6 +- .../bitbucket/8/8.5.0/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.5.0/requirements.txt | 1 + .../atlassian/bitbucket/8/8.5.1/Makefile | 6 +- .../bitbucket/8/8.5.1/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.5.1/requirements.txt | 1 + .../atlassian/bitbucket/8/8.6.0/Makefile | 6 +- .../bitbucket/8/8.6.0/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.6.0/requirements.txt | 1 + .../atlassian/bitbucket/8/8.6.1/Makefile | 6 +- .../bitbucket/8/8.6.1/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.6.1/requirements.txt | 1 + .../atlassian/bitbucket/8/8.7.0/Makefile | 6 +- .../bitbucket/8/8.7.0/kaniko-build.py | 196 ------------------ .../bitbucket/8/8.7.0/requirements.txt | 1 + .../atlassian/bitbucket/9/9.0.0/Makefile | 6 +- .../bitbucket/9/9.0.0/kaniko-build.py | 196 ------------------ .../bitbucket/9/9.0.0/requirements.txt | 1 + .../atlassian/bitbucket/latest/Makefile | 6 +- .../bitbucket/latest/kaniko-build.py | 196 ------------------ .../bitbucket/latest/requirements.txt | 1 + .../confluence/6/6.0.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.0.1/requirements.txt | 1 + .../confluence/6/6.0.2/kaniko-build.py | 196 ------------------ .../confluence/6/6.0.2/requirements.txt | 1 + .../confluence/6/6.0.3/kaniko-build.py | 196 ------------------ .../confluence/6/6.0.3/requirements.txt | 1 + .../confluence/6/6.0.4/kaniko-build.py | 196 ------------------ .../confluence/6/6.0.4/requirements.txt | 1 + .../confluence/6/6.0.5/kaniko-build.py | 196 ------------------ .../confluence/6/6.0.5/requirements.txt | 1 + .../confluence/6/6.0.6/kaniko-build.py | 196 ------------------ .../confluence/6/6.0.6/requirements.txt | 1 + .../confluence/6/6.0.7/kaniko-build.py | 196 ------------------ .../confluence/6/6.0.7/requirements.txt | 1 + .../confluence/6/6.1.0/kaniko-build.py | 196 ------------------ .../confluence/6/6.1.0/requirements.txt | 1 + .../confluence/6/6.1.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.1.1/requirements.txt | 1 + .../confluence/6/6.1.2/kaniko-build.py | 196 ------------------ .../confluence/6/6.1.2/requirements.txt | 1 + .../confluence/6/6.1.3/kaniko-build.py | 196 ------------------ .../confluence/6/6.1.3/requirements.txt | 1 + .../confluence/6/6.1.4/kaniko-build.py | 196 ------------------ .../confluence/6/6.1.4/requirements.txt | 1 + .../confluence/6/6.10.0/kaniko-build.py | 196 ------------------ .../confluence/6/6.10.0/requirements.txt | 1 + .../confluence/6/6.10.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.10.1/requirements.txt | 1 + .../confluence/6/6.10.2/kaniko-build.py | 196 ------------------ .../confluence/6/6.10.2/requirements.txt | 1 + .../confluence/6/6.10.3/kaniko-build.py | 196 ------------------ .../confluence/6/6.10.3/requirements.txt | 1 + .../confluence/6/6.11.0/kaniko-build.py | 196 ------------------ .../confluence/6/6.11.0/requirements.txt | 1 + .../confluence/6/6.11.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.11.1/requirements.txt | 1 + .../confluence/6/6.11.2/kaniko-build.py | 196 ------------------ .../confluence/6/6.11.2/requirements.txt | 1 + .../confluence/6/6.12.0/kaniko-build.py | 196 ------------------ .../confluence/6/6.12.0/requirements.txt | 1 + .../confluence/6/6.12.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.12.1/requirements.txt | 1 + .../confluence/6/6.12.2/kaniko-build.py | 196 ------------------ .../confluence/6/6.12.2/requirements.txt | 1 + .../confluence/6/6.12.3/kaniko-build.py | 196 ------------------ .../confluence/6/6.12.3/requirements.txt | 1 + .../confluence/6/6.12.4/kaniko-build.py | 196 ------------------ .../confluence/6/6.12.4/requirements.txt | 1 + .../confluence/6/6.13.0/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.0/requirements.txt | 1 + .../confluence/6/6.13.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.1/requirements.txt | 1 + .../confluence/6/6.13.10/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.10/requirements.txt | 1 + .../confluence/6/6.13.11/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.11/requirements.txt | 1 + .../confluence/6/6.13.12/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.12/requirements.txt | 1 + .../confluence/6/6.13.13/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.13/requirements.txt | 1 + .../confluence/6/6.13.15/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.15/requirements.txt | 1 + .../confluence/6/6.13.17/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.17/requirements.txt | 1 + .../confluence/6/6.13.18/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.18/requirements.txt | 1 + .../confluence/6/6.13.19/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.19/requirements.txt | 1 + .../confluence/6/6.13.2/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.2/requirements.txt | 1 + .../confluence/6/6.13.20/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.20/requirements.txt | 1 + .../confluence/6/6.13.21/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.21/requirements.txt | 1 + .../confluence/6/6.13.3/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.3/requirements.txt | 1 + .../confluence/6/6.13.4/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.4/requirements.txt | 1 + .../confluence/6/6.13.5/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.5/requirements.txt | 1 + .../confluence/6/6.13.6/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.6/requirements.txt | 1 + .../confluence/6/6.13.7/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.7/requirements.txt | 1 + .../confluence/6/6.13.8/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.8/requirements.txt | 1 + .../confluence/6/6.13.9/kaniko-build.py | 196 ------------------ .../confluence/6/6.13.9/requirements.txt | 1 + .../confluence/6/6.14.0/kaniko-build.py | 196 ------------------ .../confluence/6/6.14.0/requirements.txt | 1 + .../confluence/6/6.14.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.14.1/requirements.txt | 1 + .../confluence/6/6.14.2/kaniko-build.py | 196 ------------------ .../confluence/6/6.14.2/requirements.txt | 1 + .../confluence/6/6.14.3/kaniko-build.py | 196 ------------------ .../confluence/6/6.14.3/requirements.txt | 1 + .../confluence/6/6.15.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.15.1/requirements.txt | 1 + .../confluence/6/6.15.10/kaniko-build.py | 196 ------------------ .../confluence/6/6.15.10/requirements.txt | 1 + .../confluence/6/6.15.2/kaniko-build.py | 196 ------------------ .../confluence/6/6.15.2/requirements.txt | 1 + .../confluence/6/6.15.4/kaniko-build.py | 196 ------------------ .../confluence/6/6.15.4/requirements.txt | 1 + .../confluence/6/6.15.6/kaniko-build.py | 196 ------------------ .../confluence/6/6.15.6/requirements.txt | 1 + .../confluence/6/6.15.7/kaniko-build.py | 196 ------------------ .../confluence/6/6.15.7/requirements.txt | 1 + .../confluence/6/6.15.8/kaniko-build.py | 196 ------------------ .../confluence/6/6.15.8/requirements.txt | 1 + .../confluence/6/6.15.9/kaniko-build.py | 196 ------------------ .../confluence/6/6.15.9/requirements.txt | 1 + .../confluence/6/6.2.0/kaniko-build.py | 196 ------------------ .../confluence/6/6.2.0/requirements.txt | 1 + .../confluence/6/6.2.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.2.1/requirements.txt | 1 + .../confluence/6/6.2.2/kaniko-build.py | 196 ------------------ .../confluence/6/6.2.2/requirements.txt | 1 + .../confluence/6/6.2.3/kaniko-build.py | 196 ------------------ .../confluence/6/6.2.3/requirements.txt | 1 + .../confluence/6/6.2.4/kaniko-build.py | 196 ------------------ .../confluence/6/6.2.4/requirements.txt | 1 + .../confluence/6/6.3.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.3.1/requirements.txt | 1 + .../confluence/6/6.3.2/kaniko-build.py | 196 ------------------ .../confluence/6/6.3.2/requirements.txt | 1 + .../confluence/6/6.3.3/kaniko-build.py | 196 ------------------ .../confluence/6/6.3.3/requirements.txt | 1 + .../confluence/6/6.3.4/kaniko-build.py | 196 ------------------ .../confluence/6/6.3.4/requirements.txt | 1 + .../confluence/6/6.4.0/kaniko-build.py | 196 ------------------ .../confluence/6/6.4.0/requirements.txt | 1 + .../confluence/6/6.4.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.4.1/requirements.txt | 1 + .../confluence/6/6.4.2/kaniko-build.py | 196 ------------------ .../confluence/6/6.4.2/requirements.txt | 1 + .../confluence/6/6.4.3/kaniko-build.py | 196 ------------------ .../confluence/6/6.4.3/requirements.txt | 1 + .../confluence/6/6.5.0/kaniko-build.py | 196 ------------------ .../confluence/6/6.5.0/requirements.txt | 1 + .../confluence/6/6.5.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.5.1/requirements.txt | 1 + .../confluence/6/6.5.2/kaniko-build.py | 196 ------------------ .../confluence/6/6.5.2/requirements.txt | 1 + .../confluence/6/6.5.3/kaniko-build.py | 196 ------------------ .../confluence/6/6.5.3/requirements.txt | 1 + .../confluence/6/6.6.0/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.0/requirements.txt | 1 + .../confluence/6/6.6.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.1/requirements.txt | 1 + .../confluence/6/6.6.10/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.10/requirements.txt | 1 + .../confluence/6/6.6.11/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.11/requirements.txt | 1 + .../confluence/6/6.6.12/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.12/requirements.txt | 1 + .../confluence/6/6.6.13/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.13/requirements.txt | 1 + .../confluence/6/6.6.14/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.14/requirements.txt | 1 + .../confluence/6/6.6.15/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.15/requirements.txt | 1 + .../confluence/6/6.6.16/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.16/requirements.txt | 1 + .../confluence/6/6.6.17/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.17/requirements.txt | 1 + .../confluence/6/6.6.2/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.2/requirements.txt | 1 + .../confluence/6/6.6.3/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.3/requirements.txt | 1 + .../confluence/6/6.6.4/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.4/requirements.txt | 1 + .../confluence/6/6.6.5/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.5/requirements.txt | 1 + .../confluence/6/6.6.6/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.6/requirements.txt | 1 + .../confluence/6/6.6.7/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.7/requirements.txt | 1 + .../confluence/6/6.6.8/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.8/requirements.txt | 1 + .../confluence/6/6.6.9/kaniko-build.py | 196 ------------------ .../confluence/6/6.6.9/requirements.txt | 1 + .../confluence/6/6.7.0/kaniko-build.py | 196 ------------------ .../confluence/6/6.7.0/requirements.txt | 1 + .../confluence/6/6.7.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.7.1/requirements.txt | 1 + .../confluence/6/6.7.2/kaniko-build.py | 196 ------------------ .../confluence/6/6.7.2/requirements.txt | 1 + .../confluence/6/6.7.3/kaniko-build.py | 196 ------------------ .../confluence/6/6.7.3/requirements.txt | 1 + .../confluence/6/6.8.0/kaniko-build.py | 196 ------------------ .../confluence/6/6.8.0/requirements.txt | 1 + .../confluence/6/6.8.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.8.1/requirements.txt | 1 + .../confluence/6/6.8.2/kaniko-build.py | 196 ------------------ .../confluence/6/6.8.2/requirements.txt | 1 + .../confluence/6/6.8.3/kaniko-build.py | 196 ------------------ .../confluence/6/6.8.3/requirements.txt | 1 + .../confluence/6/6.8.5/kaniko-build.py | 196 ------------------ .../confluence/6/6.8.5/requirements.txt | 1 + .../confluence/6/6.9.0/kaniko-build.py | 196 ------------------ .../confluence/6/6.9.0/requirements.txt | 1 + .../confluence/6/6.9.1/kaniko-build.py | 196 ------------------ .../confluence/6/6.9.1/requirements.txt | 1 + .../confluence/6/6.9.3/kaniko-build.py | 196 ------------------ .../confluence/6/6.9.3/requirements.txt | 1 + .../atlassian/confluence/7/7.19.0/Makefile | 6 +- .../confluence/7/7.19.0/kaniko-build.py | 196 ------------------ .../confluence/7/7.19.0/requirements.txt | 1 + .../atlassian/confluence/7/7.19.1/Makefile | 6 +- .../confluence/7/7.19.1/kaniko-build.py | 196 ------------------ .../confluence/7/7.19.1/requirements.txt | 1 + .../atlassian/confluence/7/7.19.16/Makefile | 6 +- .../confluence/7/7.19.16/kaniko-build.py | 196 ------------------ .../confluence/7/7.19.16/requirements.txt | 1 + .../atlassian/confluence/7/7.19.17/Makefile | 6 +- .../confluence/7/7.19.17/kaniko-build.py | 196 ------------------ .../confluence/7/7.19.17/requirements.txt | 1 + .../atlassian/confluence/7/7.19.18/Makefile | 6 +- .../confluence/7/7.19.18/kaniko-build.py | 196 ------------------ .../confluence/7/7.19.18/requirements.txt | 1 + .../atlassian/confluence/7/7.19.2/Makefile | 6 +- .../confluence/7/7.19.2/kaniko-build.py | 196 ------------------ .../confluence/7/7.19.2/requirements.txt | 1 + .../atlassian/confluence/7/7.19.3/Makefile | 6 +- .../confluence/7/7.19.3/kaniko-build.py | 196 ------------------ .../confluence/7/7.19.3/requirements.txt | 1 + .../atlassian/confluence/7/7.19.4/Makefile | 6 +- .../confluence/7/7.19.4/kaniko-build.py | 196 ------------------ .../confluence/7/7.19.4/requirements.txt | 1 + .../atlassian/confluence/7/7.20.0/Makefile | 6 +- .../confluence/7/7.20.0/kaniko-build.py | 196 ------------------ .../confluence/7/7.20.0/requirements.txt | 1 + .../atlassian/confluence/7/7.20.1/Makefile | 6 +- .../confluence/7/7.20.1/kaniko-build.py | 196 ------------------ .../confluence/7/7.20.1/requirements.txt | 1 + .../atlassian/confluence/7/7.20.2/Makefile | 6 +- .../confluence/7/7.20.2/kaniko-build.py | 196 ------------------ .../confluence/7/7.20.2/requirements.txt | 1 + .../atlassian/confluence/7/7.20.3/Makefile | 6 +- .../confluence/7/7.20.3/kaniko-build.py | 196 ------------------ .../confluence/7/7.20.3/requirements.txt | 1 + .../atlassian/confluence/8/8.0.0/Makefile | 6 +- .../confluence/8/8.0.0/kaniko-build.py | 196 ------------------ .../confluence/8/8.0.0/requirements.txt | 1 + .../atlassian/confluence/8/8.0.1/Makefile | 6 +- .../confluence/8/8.0.1/kaniko-build.py | 196 ------------------ .../confluence/8/8.0.1/requirements.txt | 1 + .../atlassian/confluence/8/8.0.2/Makefile | 6 +- .../confluence/8/8.0.2/kaniko-build.py | 196 ------------------ .../confluence/8/8.0.2/requirements.txt | 1 + .../atlassian/confluence/8/8.4.0/Makefile | 6 +- .../confluence/8/8.4.0/kaniko-build.py | 196 ------------------ .../confluence/8/8.4.0/requirements.txt | 1 + .../atlassian/confluence/8/8.5.3/Makefile | 6 +- .../confluence/8/8.5.3/kaniko-build.py | 196 ------------------ .../confluence/8/8.5.3/requirements.txt | 1 + .../atlassian/confluence/8/8.6.1/Makefile | 6 +- .../confluence/8/8.6.1/kaniko-build.py | 196 ------------------ .../confluence/8/8.6.1/requirements.txt | 1 + .../atlassian/confluence/8/8.7.2/Makefile | 6 +- .../confluence/8/8.7.2/kaniko-build.py | 196 ------------------ .../confluence/8/8.7.2/requirements.txt | 1 + .../atlassian/confluence/8/8.8.1/Makefile | 6 +- .../confluence/8/8.8.1/kaniko-build.py | 196 ------------------ .../confluence/8/8.8.1/requirements.txt | 1 + .../atlassian/confluence/8/8.9.5/Makefile | 6 +- .../confluence/8/8.9.5/kaniko-build.py | 196 ------------------ .../confluence/8/8.9.5/requirements.txt | 1 + .../atlassian/confluence/9/9.0.0/Makefile | 6 +- .../confluence/9/9.0.0/kaniko-build.py | 196 ------------------ .../confluence/9/9.0.0/requirements.txt | 1 + .../atlassian/confluence/9/9.0.1/Makefile | 6 +- .../confluence/9/9.0.1/kaniko-build.py | 196 ------------------ .../confluence/9/9.0.1/requirements.txt | 1 + .../atlassian/confluence/latest/Makefile | 6 +- .../confluence/latest/kaniko-build.py | 196 ------------------ .../confluence/latest/requirements.txt | 1 + .../atlassian/confluence/templates/5/Makefile | 6 +- .../confluence/templates/5/kaniko-build.py | 196 ------------------ .../confluence/templates/5/requirements.txt | 1 + .../atlassian/confluence/templates/6/Makefile | 6 +- .../confluence/templates/6/kaniko-build.py | 196 ------------------ .../confluence/templates/6/requirements.txt | 1 + .../atlassian/crowd/5/5.1.1/Makefile | 6 +- .../atlassian/crowd/5/5.1.1/kaniko-build.py | 196 ------------------ .../atlassian/crowd/5/5.1.1/requirements.txt | 1 + .../ecosystem/atlassian/crowd/latest/Makefile | 6 +- .../atlassian/crowd/latest/kaniko-build.py | 196 ------------------ .../atlassian/crowd/latest/requirements.txt | 1 + .../crucible/1/1.0.3/kaniko-build.py | 196 ------------------ .../crucible/1/1.0.3/requirements.txt | 1 + .../crucible/1/1.0.4/kaniko-build.py | 196 ------------------ .../crucible/1/1.0.4/requirements.txt | 1 + .../atlassian/crucible/1/1.0/kaniko-build.py | 196 ------------------ .../atlassian/crucible/1/1.0/requirements.txt | 1 + .../crucible/1/1.1.1/kaniko-build.py | 196 ------------------ .../crucible/1/1.1.1/requirements.txt | 1 + .../crucible/1/1.1.2/kaniko-build.py | 196 ------------------ .../crucible/1/1.1.2/requirements.txt | 1 + .../crucible/1/1.1.3/kaniko-build.py | 196 ------------------ .../crucible/1/1.1.3/requirements.txt | 1 + .../crucible/1/1.1.4/kaniko-build.py | 196 ------------------ .../crucible/1/1.1.4/requirements.txt | 1 + .../atlassian/crucible/1/1.1/kaniko-build.py | 196 ------------------ .../atlassian/crucible/1/1.1/requirements.txt | 1 + .../crucible/1/1.2.1/kaniko-build.py | 196 ------------------ .../crucible/1/1.2.1/requirements.txt | 1 + .../crucible/1/1.2.2/kaniko-build.py | 196 ------------------ .../crucible/1/1.2.2/requirements.txt | 1 + .../crucible/1/1.2.3/kaniko-build.py | 196 ------------------ .../crucible/1/1.2.3/requirements.txt | 1 + .../atlassian/crucible/1/1.2/kaniko-build.py | 196 ------------------ .../atlassian/crucible/1/1.2/requirements.txt | 1 + .../crucible/1/1.5.1/kaniko-build.py | 196 ------------------ .../crucible/1/1.5.1/requirements.txt | 1 + .../crucible/1/1.5.2/kaniko-build.py | 196 ------------------ .../crucible/1/1.5.2/requirements.txt | 1 + .../crucible/1/1.5.3/kaniko-build.py | 196 ------------------ .../crucible/1/1.5.3/requirements.txt | 1 + .../crucible/1/1.5.4/kaniko-build.py | 196 ------------------ .../crucible/1/1.5.4/requirements.txt | 1 + .../atlassian/crucible/1/1.5/kaniko-build.py | 196 ------------------ .../atlassian/crucible/1/1.5/requirements.txt | 1 + .../crucible/1/1.6.0/kaniko-build.py | 196 ------------------ .../crucible/1/1.6.0/requirements.txt | 1 + .../crucible/1/1.6.0Beta1/kaniko-build.py | 196 ------------------ .../crucible/1/1.6.0Beta1/requirements.txt | 1 + .../crucible/1/1.6.0Beta2/kaniko-build.py | 196 ------------------ .../crucible/1/1.6.0Beta2/requirements.txt | 1 + .../crucible/1/1.6.1/kaniko-build.py | 196 ------------------ .../crucible/1/1.6.1/requirements.txt | 1 + .../crucible/1/1.6.2.1/kaniko-build.py | 196 ------------------ .../crucible/1/1.6.2.1/requirements.txt | 1 + .../crucible/1/1.6.2/kaniko-build.py | 196 ------------------ .../crucible/1/1.6.2/requirements.txt | 1 + .../crucible/1/1.6.3/kaniko-build.py | 196 ------------------ .../crucible/1/1.6.3/requirements.txt | 1 + .../crucible/1/1.6.4/kaniko-build.py | 196 ------------------ .../crucible/1/1.6.4/requirements.txt | 1 + .../crucible/1/1.6.5.a/kaniko-build.py | 196 ------------------ .../crucible/1/1.6.5.a/requirements.txt | 1 + .../crucible/1/1.6.5/kaniko-build.py | 196 ------------------ .../crucible/1/1.6.5/requirements.txt | 1 + .../crucible/1/1.6.5a/kaniko-build.py | 196 ------------------ .../crucible/1/1.6.5a/requirements.txt | 1 + .../crucible/1/1.6.6/kaniko-build.py | 196 ------------------ .../crucible/1/1.6.6/requirements.txt | 1 + .../atlassian/crucible/templates/1/Makefile | 6 +- .../crucible/templates/1/kaniko-build.py | 196 ------------------ .../crucible/templates/1/requirements.txt | 1 + .../2/2.0.0.B3/kaniko-build.py | 196 ------------------ .../2/2.0.0.B3/requirements.txt | 1 + .../2/2.0.0.RC1/kaniko-build.py | 196 ------------------ .../2/2.0.0.RC1/requirements.txt | 1 + .../2/2.0.0.RC2/kaniko-build.py | 196 ------------------ .../2/2.0.0.RC2/requirements.txt | 1 + .../2/2.0.0.RC3/kaniko-build.py | 196 ------------------ .../2/2.0.0.RC3/requirements.txt | 1 + .../fisheye-crucible/2/2.0.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.0.0/requirements.txt | 1 + .../fisheye-crucible/2/2.0.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.0.1/requirements.txt | 1 + .../fisheye-crucible/2/2.0.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.0.2/requirements.txt | 1 + .../fisheye-crucible/2/2.0.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.0.3/requirements.txt | 1 + .../fisheye-crucible/2/2.0.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.0.4/requirements.txt | 1 + .../fisheye-crucible/2/2.0.5/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.0.5/requirements.txt | 1 + .../fisheye-crucible/2/2.0.6/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.0.6/requirements.txt | 1 + .../2/2.1.0.M2cc/kaniko-build.py | 196 ------------------ .../2/2.1.0.M2cc/requirements.txt | 1 + .../2/2.1.0.RC1/kaniko-build.py | 196 ------------------ .../2/2.1.0.RC1/requirements.txt | 1 + .../fisheye-crucible/2/2.1.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.1.0/requirements.txt | 1 + .../fisheye-crucible/2/2.1.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.1.1/requirements.txt | 1 + .../fisheye-crucible/2/2.1.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.1.2/requirements.txt | 1 + .../fisheye-crucible/2/2.1.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.1.3/requirements.txt | 1 + .../fisheye-crucible/2/2.1.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.1.4/requirements.txt | 1 + .../fisheye-crucible/2/2.10.0/kaniko-build.py | 196 ------------------ .../2/2.10.0/requirements.txt | 1 + .../fisheye-crucible/2/2.10.1/kaniko-build.py | 196 ------------------ .../2/2.10.1/requirements.txt | 1 + .../fisheye-crucible/2/2.10.2/kaniko-build.py | 196 ------------------ .../2/2.10.2/requirements.txt | 1 + .../fisheye-crucible/2/2.10.3/kaniko-build.py | 196 ------------------ .../2/2.10.3/requirements.txt | 1 + .../fisheye-crucible/2/2.10.4/kaniko-build.py | 196 ------------------ .../2/2.10.4/requirements.txt | 1 + .../fisheye-crucible/2/2.10.5/kaniko-build.py | 196 ------------------ .../2/2.10.5/requirements.txt | 1 + .../fisheye-crucible/2/2.10.6/kaniko-build.py | 196 ------------------ .../2/2.10.6/requirements.txt | 1 + .../fisheye-crucible/2/2.10.7/kaniko-build.py | 196 ------------------ .../2/2.10.7/requirements.txt | 1 + .../fisheye-crucible/2/2.10.8/kaniko-build.py | 196 ------------------ .../2/2.10.8/requirements.txt | 1 + .../fisheye-crucible/2/2.2.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.2.0/requirements.txt | 1 + .../fisheye-crucible/2/2.2.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.2.1/requirements.txt | 1 + .../fisheye-crucible/2/2.2.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.2.3/requirements.txt | 1 + .../fisheye-crucible/2/2.3.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.3.0/requirements.txt | 1 + .../fisheye-crucible/2/2.3.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.3.1/requirements.txt | 1 + .../fisheye-crucible/2/2.3.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.3.2/requirements.txt | 1 + .../fisheye-crucible/2/2.3.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.3.3/requirements.txt | 1 + .../fisheye-crucible/2/2.3.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.3.4/requirements.txt | 1 + .../fisheye-crucible/2/2.3.5/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.3.5/requirements.txt | 1 + .../fisheye-crucible/2/2.3.6/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.3.6/requirements.txt | 1 + .../fisheye-crucible/2/2.3.7/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.3.7/requirements.txt | 1 + .../fisheye-crucible/2/2.3.8/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.3.8/requirements.txt | 1 + .../fisheye-crucible/2/2.4.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.4.0/requirements.txt | 1 + .../fisheye-crucible/2/2.4.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.4.1/requirements.txt | 1 + .../fisheye-crucible/2/2.4.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.4.2/requirements.txt | 1 + .../fisheye-crucible/2/2.4.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.4.3/requirements.txt | 1 + .../fisheye-crucible/2/2.4.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.4.4/requirements.txt | 1 + .../fisheye-crucible/2/2.4.5/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.4.5/requirements.txt | 1 + .../fisheye-crucible/2/2.4.6/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.4.6/requirements.txt | 1 + .../fisheye-crucible/2/2.5.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.5.0/requirements.txt | 1 + .../fisheye-crucible/2/2.5.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.5.1/requirements.txt | 1 + .../fisheye-crucible/2/2.5.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.5.2/requirements.txt | 1 + .../fisheye-crucible/2/2.5.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.5.3/requirements.txt | 1 + .../fisheye-crucible/2/2.5.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.5.4/requirements.txt | 1 + .../fisheye-crucible/2/2.5.5/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.5.5/requirements.txt | 1 + .../fisheye-crucible/2/2.5.6/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.5.6/requirements.txt | 1 + .../fisheye-crucible/2/2.5.7/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.5.7/requirements.txt | 1 + .../fisheye-crucible/2/2.5.8/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.5.8/requirements.txt | 1 + .../fisheye-crucible/2/2.5.9/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.5.9/requirements.txt | 1 + .../fisheye-crucible/2/2.6.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.6.0/requirements.txt | 1 + .../fisheye-crucible/2/2.6.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.6.1/requirements.txt | 1 + .../fisheye-crucible/2/2.6.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.6.2/requirements.txt | 1 + .../fisheye-crucible/2/2.6.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.6.3/requirements.txt | 1 + .../fisheye-crucible/2/2.6.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.6.4/requirements.txt | 1 + .../fisheye-crucible/2/2.6.5/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.6.5/requirements.txt | 1 + .../fisheye-crucible/2/2.6.6/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.6.6/requirements.txt | 1 + .../fisheye-crucible/2/2.6.7/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.6.7/requirements.txt | 1 + .../fisheye-crucible/2/2.6.8/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.6.8/requirements.txt | 1 + .../fisheye-crucible/2/2.6.9/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.6.9/requirements.txt | 1 + .../2/2.7.0-EAP-1/kaniko-build.py | 196 ------------------ .../2/2.7.0-EAP-1/requirements.txt | 1 + .../2/2.7.0-EAP-2/kaniko-build.py | 196 ------------------ .../2/2.7.0-EAP-2/requirements.txt | 1 + .../fisheye-crucible/2/2.7.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.7.0/requirements.txt | 1 + .../fisheye-crucible/2/2.7.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.7.1/requirements.txt | 1 + .../fisheye-crucible/2/2.7.10/kaniko-build.py | 196 ------------------ .../2/2.7.10/requirements.txt | 1 + .../fisheye-crucible/2/2.7.11/kaniko-build.py | 196 ------------------ .../2/2.7.11/requirements.txt | 1 + .../fisheye-crucible/2/2.7.12/kaniko-build.py | 196 ------------------ .../2/2.7.12/requirements.txt | 1 + .../fisheye-crucible/2/2.7.13/kaniko-build.py | 196 ------------------ .../2/2.7.13/requirements.txt | 1 + .../fisheye-crucible/2/2.7.14/kaniko-build.py | 196 ------------------ .../2/2.7.14/requirements.txt | 1 + .../fisheye-crucible/2/2.7.15/kaniko-build.py | 196 ------------------ .../2/2.7.15/requirements.txt | 1 + .../fisheye-crucible/2/2.7.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.7.2/requirements.txt | 1 + .../fisheye-crucible/2/2.7.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.7.3/requirements.txt | 1 + .../fisheye-crucible/2/2.7.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.7.4/requirements.txt | 1 + .../fisheye-crucible/2/2.7.5/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.7.5/requirements.txt | 1 + .../fisheye-crucible/2/2.7.6/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.7.6/requirements.txt | 1 + .../fisheye-crucible/2/2.7.7/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.7.7/requirements.txt | 1 + .../fisheye-crucible/2/2.7.8/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.7.8/requirements.txt | 1 + .../fisheye-crucible/2/2.7.9/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.7.9/requirements.txt | 1 + .../2/2.8.0-m1/kaniko-build.py | 196 ------------------ .../2/2.8.0-m1/requirements.txt | 1 + .../fisheye-crucible/2/2.8.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.8.0/requirements.txt | 1 + .../fisheye-crucible/2/2.8.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.8.1/requirements.txt | 1 + .../fisheye-crucible/2/2.8.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.8.2/requirements.txt | 1 + .../fisheye-crucible/2/2.9.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.9.0/requirements.txt | 1 + .../fisheye-crucible/2/2.9.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.9.1/requirements.txt | 1 + .../fisheye-crucible/2/2.9.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/2/2.9.2/requirements.txt | 1 + .../fisheye-crucible/3/3.0.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.0.0/requirements.txt | 1 + .../fisheye-crucible/3/3.0.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.0.1/requirements.txt | 1 + .../fisheye-crucible/3/3.0.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.0.2/requirements.txt | 1 + .../fisheye-crucible/3/3.0.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.0.3/requirements.txt | 1 + .../fisheye-crucible/3/3.0.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.0.4/requirements.txt | 1 + .../fisheye-crucible/3/3.1.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.1.0/requirements.txt | 1 + .../fisheye-crucible/3/3.1.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.1.1/requirements.txt | 1 + .../fisheye-crucible/3/3.1.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.1.2/requirements.txt | 1 + .../fisheye-crucible/3/3.1.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.1.3/requirements.txt | 1 + .../fisheye-crucible/3/3.1.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.1.4/requirements.txt | 1 + .../fisheye-crucible/3/3.1.5/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.1.5/requirements.txt | 1 + .../fisheye-crucible/3/3.1.6/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.1.6/requirements.txt | 1 + .../fisheye-crucible/3/3.1.7/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.1.7/requirements.txt | 1 + .../fisheye-crucible/3/3.10.1/kaniko-build.py | 196 ------------------ .../3/3.10.1/requirements.txt | 1 + .../fisheye-crucible/3/3.10.2/kaniko-build.py | 196 ------------------ .../3/3.10.2/requirements.txt | 1 + .../fisheye-crucible/3/3.10.3/kaniko-build.py | 196 ------------------ .../3/3.10.3/requirements.txt | 1 + .../fisheye-crucible/3/3.10.4/kaniko-build.py | 196 ------------------ .../3/3.10.4/requirements.txt | 1 + .../fisheye-crucible/3/3.2.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.2.0/requirements.txt | 1 + .../fisheye-crucible/3/3.2.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.2.1/requirements.txt | 1 + .../fisheye-crucible/3/3.2.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.2.2/requirements.txt | 1 + .../fisheye-crucible/3/3.2.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.2.3/requirements.txt | 1 + .../fisheye-crucible/3/3.2.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.2.4/requirements.txt | 1 + .../fisheye-crucible/3/3.2.5/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.2.5/requirements.txt | 1 + .../fisheye-crucible/3/3.3.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.3.0/requirements.txt | 1 + .../fisheye-crucible/3/3.3.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.3.1/requirements.txt | 1 + .../fisheye-crucible/3/3.3.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.3.2/requirements.txt | 1 + .../fisheye-crucible/3/3.3.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.3.3/requirements.txt | 1 + .../fisheye-crucible/3/3.3.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.3.4/requirements.txt | 1 + .../fisheye-crucible/3/3.4.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.4.0/requirements.txt | 1 + .../fisheye-crucible/3/3.4.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.4.3/requirements.txt | 1 + .../fisheye-crucible/3/3.4.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.4.4/requirements.txt | 1 + .../fisheye-crucible/3/3.4.5/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.4.5/requirements.txt | 1 + .../fisheye-crucible/3/3.4.6/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.4.6/requirements.txt | 1 + .../fisheye-crucible/3/3.4.7/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.4.7/requirements.txt | 1 + .../fisheye-crucible/3/3.5.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.5.0/requirements.txt | 1 + .../fisheye-crucible/3/3.5.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.5.1/requirements.txt | 1 + .../fisheye-crucible/3/3.5.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.5.2/requirements.txt | 1 + .../fisheye-crucible/3/3.5.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.5.3/requirements.txt | 1 + .../fisheye-crucible/3/3.5.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.5.4/requirements.txt | 1 + .../fisheye-crucible/3/3.5.5/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.5.5/requirements.txt | 1 + .../fisheye-crucible/3/3.6.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.6.0/requirements.txt | 1 + .../fisheye-crucible/3/3.6.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.6.1/requirements.txt | 1 + .../fisheye-crucible/3/3.6.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.6.2/requirements.txt | 1 + .../fisheye-crucible/3/3.6.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.6.3/requirements.txt | 1 + .../fisheye-crucible/3/3.6.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.6.4/requirements.txt | 1 + .../fisheye-crucible/3/3.7.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.7.0/requirements.txt | 1 + .../fisheye-crucible/3/3.7.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.7.1/requirements.txt | 1 + .../fisheye-crucible/3/3.8.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.8.0/requirements.txt | 1 + .../fisheye-crucible/3/3.8.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.8.1/requirements.txt | 1 + .../fisheye-crucible/3/3.9.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.9.0/requirements.txt | 1 + .../fisheye-crucible/3/3.9.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.9.1/requirements.txt | 1 + .../fisheye-crucible/3/3.9.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/3/3.9.2/requirements.txt | 1 + .../fisheye-crucible/4/4.0.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.0.2/requirements.txt | 1 + .../fisheye-crucible/4/4.0.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.0.3/requirements.txt | 1 + .../fisheye-crucible/4/4.0.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.0.4/requirements.txt | 1 + .../fisheye-crucible/4/4.1.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.1.0/requirements.txt | 1 + .../fisheye-crucible/4/4.1.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.1.1/requirements.txt | 1 + .../fisheye-crucible/4/4.1.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.1.2/requirements.txt | 1 + .../fisheye-crucible/4/4.1.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.1.3/requirements.txt | 1 + .../fisheye-crucible/4/4.2.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.2.0/requirements.txt | 1 + .../fisheye-crucible/4/4.2.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.2.1/requirements.txt | 1 + .../fisheye-crucible/4/4.2.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.2.2/requirements.txt | 1 + .../fisheye-crucible/4/4.2.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.2.3/requirements.txt | 1 + .../fisheye-crucible/4/4.3.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.3.0/requirements.txt | 1 + .../fisheye-crucible/4/4.3.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.3.1/requirements.txt | 1 + .../fisheye-crucible/4/4.3.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.3.2/requirements.txt | 1 + .../fisheye-crucible/4/4.3.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.3.3/requirements.txt | 1 + .../fisheye-crucible/4/4.4.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.4.0/requirements.txt | 1 + .../fisheye-crucible/4/4.4.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.4.1/requirements.txt | 1 + .../fisheye-crucible/4/4.4.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.4.2/requirements.txt | 1 + .../fisheye-crucible/4/4.4.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.4.3/requirements.txt | 1 + .../fisheye-crucible/4/4.4.5/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.4.5/requirements.txt | 1 + .../fisheye-crucible/4/4.4.6/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.4.6/requirements.txt | 1 + .../fisheye-crucible/4/4.4.7/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.4.7/requirements.txt | 1 + .../fisheye-crucible/4/4.5.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.5.0/requirements.txt | 1 + .../fisheye-crucible/4/4.5.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.5.1/requirements.txt | 1 + .../fisheye-crucible/4/4.5.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.5.2/requirements.txt | 1 + .../fisheye-crucible/4/4.5.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.5.3/requirements.txt | 1 + .../fisheye-crucible/4/4.5.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.5.4/requirements.txt | 1 + .../fisheye-crucible/4/4.6.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.6.0/requirements.txt | 1 + .../fisheye-crucible/4/4.6.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.6.1/requirements.txt | 1 + .../fisheye-crucible/4/4.7.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.7.0/requirements.txt | 1 + .../fisheye-crucible/4/4.7.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.7.1/requirements.txt | 1 + .../fisheye-crucible/4/4.7.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.7.2/requirements.txt | 1 + .../fisheye-crucible/4/4.7.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.7.3/requirements.txt | 1 + .../fisheye-crucible/4/4.8.0/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.8.0/requirements.txt | 1 + .../fisheye-crucible/4/4.8.1/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.8.1/requirements.txt | 1 + .../fisheye-crucible/4/4.8.2/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.8.2/requirements.txt | 1 + .../fisheye-crucible/4/4.8.3/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.8.3/requirements.txt | 1 + .../fisheye-crucible/4/4.8.4/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.8.4/requirements.txt | 1 + .../fisheye-crucible/4/4.8.5/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.8.5/requirements.txt | 1 + .../fisheye-crucible/4/4.8.6/kaniko-build.py | 196 ------------------ .../fisheye-crucible/4/4.8.6/requirements.txt | 1 + .../fisheye-crucible/latest/Makefile | 6 +- .../fisheye-crucible/latest/kaniko-build.py | 196 ------------------ .../fisheye-crucible/latest/requirements.txt | 1 + .../fisheye-crucible/templates/2/Makefile | 6 +- .../templates/2/kaniko-build.py | 196 ------------------ .../templates/2/requirements.txt | 1 + .../fisheye-crucible/templates/3/Makefile | 6 +- .../templates/3/kaniko-build.py | 196 ------------------ .../templates/3/requirements.txt | 1 + .../fisheye-crucible/templates/4/Makefile | 6 +- .../templates/4/kaniko-build.py | 196 ------------------ .../templates/4/requirements.txt | 1 + .../fisheye/1/1.0.1a/kaniko-build.py | 196 ------------------ .../fisheye/1/1.0.1a/requirements.txt | 1 + .../atlassian/fisheye/1/1.1.3/kaniko-build.py | 196 ------------------ .../fisheye/1/1.1.3/requirements.txt | 1 + .../atlassian/fisheye/1/1.2.5/kaniko-build.py | 196 ------------------ .../fisheye/1/1.2.5/requirements.txt | 1 + .../atlassian/fisheye/1/1.3.3/kaniko-build.py | 196 ------------------ .../fisheye/1/1.3.3/requirements.txt | 1 + .../atlassian/fisheye/1/1.3.4/kaniko-build.py | 196 ------------------ .../fisheye/1/1.3.4/requirements.txt | 1 + .../atlassian/fisheye/1/1.3.5/kaniko-build.py | 196 ------------------ .../fisheye/1/1.3.5/requirements.txt | 1 + .../atlassian/fisheye/1/1.3.6/kaniko-build.py | 196 ------------------ .../fisheye/1/1.3.6/requirements.txt | 1 + .../atlassian/fisheye/1/1.3.7/kaniko-build.py | 196 ------------------ .../fisheye/1/1.3.7/requirements.txt | 1 + .../atlassian/fisheye/1/1.3.8/kaniko-build.py | 196 ------------------ .../fisheye/1/1.3.8/requirements.txt | 1 + .../atlassian/fisheye/1/1.4.1/kaniko-build.py | 196 ------------------ .../fisheye/1/1.4.1/requirements.txt | 1 + .../atlassian/fisheye/1/1.4.2/kaniko-build.py | 196 ------------------ .../fisheye/1/1.4.2/requirements.txt | 1 + .../atlassian/fisheye/1/1.4.3/kaniko-build.py | 196 ------------------ .../fisheye/1/1.4.3/requirements.txt | 1 + .../atlassian/fisheye/1/1.4/kaniko-build.py | 196 ------------------ .../atlassian/fisheye/1/1.4/requirements.txt | 1 + .../atlassian/fisheye/1/1.5.1/kaniko-build.py | 196 ------------------ .../fisheye/1/1.5.1/requirements.txt | 1 + .../atlassian/fisheye/1/1.5.2/kaniko-build.py | 196 ------------------ .../fisheye/1/1.5.2/requirements.txt | 1 + .../atlassian/fisheye/1/1.5.3/kaniko-build.py | 196 ------------------ .../fisheye/1/1.5.3/requirements.txt | 1 + .../atlassian/fisheye/1/1.5.4/kaniko-build.py | 196 ------------------ .../fisheye/1/1.5.4/requirements.txt | 1 + .../atlassian/fisheye/1/1.5/kaniko-build.py | 196 ------------------ .../atlassian/fisheye/1/1.5/requirements.txt | 1 + .../atlassian/fisheye/1/1.6.0/kaniko-build.py | 196 ------------------ .../fisheye/1/1.6.0/requirements.txt | 1 + .../fisheye/1/1.6.0Beta1/kaniko-build.py | 196 ------------------ .../fisheye/1/1.6.0Beta1/requirements.txt | 1 + .../fisheye/1/1.6.0Beta2/kaniko-build.py | 196 ------------------ .../fisheye/1/1.6.0Beta2/requirements.txt | 1 + .../atlassian/fisheye/1/1.6.1/kaniko-build.py | 196 ------------------ .../fisheye/1/1.6.1/requirements.txt | 1 + .../atlassian/fisheye/1/1.6.3/kaniko-build.py | 196 ------------------ .../fisheye/1/1.6.3/requirements.txt | 1 + .../atlassian/fisheye/1/1.6.4/kaniko-build.py | 196 ------------------ .../fisheye/1/1.6.4/requirements.txt | 1 + .../fisheye/1/1.6.5.a/kaniko-build.py | 196 ------------------ .../fisheye/1/1.6.5.a/requirements.txt | 1 + .../atlassian/fisheye/1/1.6.5/kaniko-build.py | 196 ------------------ .../fisheye/1/1.6.5/requirements.txt | 1 + .../fisheye/1/1.6.5a/kaniko-build.py | 196 ------------------ .../fisheye/1/1.6.5a/requirements.txt | 1 + .../atlassian/fisheye/1/1.6.6/kaniko-build.py | 196 ------------------ .../fisheye/1/1.6.6/requirements.txt | 1 + .../atlassian/fisheye/templates/1/Makefile | 6 +- .../fisheye/templates/1/kaniko-build.py | 196 ------------------ .../fisheye/templates/1/requirements.txt | 1 + .../ecosystem/atlassian/jira/4/4.1.1/Makefile | 6 +- .../atlassian/jira/4/4.1.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.1.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/4/4.1.2/Makefile | 6 +- .../atlassian/jira/4/4.1.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.1.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/4/4.2.1/Makefile | 6 +- .../atlassian/jira/4/4.2.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.2.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/4/4.2.2/Makefile | 6 +- .../atlassian/jira/4/4.2.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.2.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/4/4.2.3/Makefile | 6 +- .../atlassian/jira/4/4.2.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.2.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/4/4.2.4/Makefile | 6 +- .../atlassian/jira/4/4.2.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.2.4/requirements.txt | 1 + linux/ecosystem/atlassian/jira/4/4.2/Makefile | 6 +- .../atlassian/jira/4/4.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/4/4.3.1/Makefile | 6 +- .../atlassian/jira/4/4.3.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.3.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/4/4.3.2/Makefile | 6 +- .../atlassian/jira/4/4.3.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.3.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/4/4.3.3/Makefile | 6 +- .../atlassian/jira/4/4.3.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.3.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/4/4.3.4/Makefile | 6 +- .../atlassian/jira/4/4.3.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.3.4/requirements.txt | 1 + linux/ecosystem/atlassian/jira/4/4.3/Makefile | 6 +- .../atlassian/jira/4/4.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/4/4.4.1/Makefile | 6 +- .../atlassian/jira/4/4.4.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.4.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/4/4.4.3/Makefile | 6 +- .../atlassian/jira/4/4.4.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.4.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/4/4.4.4/Makefile | 6 +- .../atlassian/jira/4/4.4.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.4.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/4/4.4.5/Makefile | 6 +- .../atlassian/jira/4/4.4.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.4.5/requirements.txt | 1 + linux/ecosystem/atlassian/jira/4/4.4/Makefile | 6 +- .../atlassian/jira/4/4.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/4/4.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.0.1/Makefile | 6 +- .../atlassian/jira/5/5.0.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.0.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.0.2/Makefile | 6 +- .../atlassian/jira/5/5.0.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.0.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.0.3/Makefile | 6 +- .../atlassian/jira/5/5.0.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.0.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.0.4/Makefile | 6 +- .../atlassian/jira/5/5.0.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.0.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.0.5/Makefile | 6 +- .../atlassian/jira/5/5.0.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.0.5/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.0.6/Makefile | 6 +- .../atlassian/jira/5/5.0.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.0.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.0.7/Makefile | 6 +- .../atlassian/jira/5/5.0.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.0.7/requirements.txt | 1 + linux/ecosystem/atlassian/jira/5/5.0/Makefile | 6 +- .../atlassian/jira/5/5.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.1.1/Makefile | 6 +- .../atlassian/jira/5/5.1.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.1.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.1.2/Makefile | 6 +- .../atlassian/jira/5/5.1.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.1.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.1.3/Makefile | 6 +- .../atlassian/jira/5/5.1.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.1.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.1.4/Makefile | 6 +- .../atlassian/jira/5/5.1.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.1.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.1.5/Makefile | 6 +- .../atlassian/jira/5/5.1.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.1.5/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.1.6/Makefile | 6 +- .../atlassian/jira/5/5.1.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.1.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.1.7/Makefile | 6 +- .../atlassian/jira/5/5.1.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.1.7/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.1.8/Makefile | 6 +- .../atlassian/jira/5/5.1.8/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.1.8/requirements.txt | 1 + linux/ecosystem/atlassian/jira/5/5.1/Makefile | 6 +- .../atlassian/jira/5/5.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.2.1/Makefile | 6 +- .../atlassian/jira/5/5.2.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.2.1/requirements.txt | 1 + .../atlassian/jira/5/5.2.10/Makefile | 6 +- .../atlassian/jira/5/5.2.10/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.2.10/requirements.txt | 1 + .../atlassian/jira/5/5.2.11/Makefile | 6 +- .../atlassian/jira/5/5.2.11/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.2.11/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.2.2/Makefile | 6 +- .../atlassian/jira/5/5.2.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.2.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.2.3/Makefile | 6 +- .../atlassian/jira/5/5.2.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.2.3/requirements.txt | 1 + .../atlassian/jira/5/5.2.4.1/Makefile | 6 +- .../atlassian/jira/5/5.2.4.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.2.4.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.2.4/Makefile | 6 +- .../atlassian/jira/5/5.2.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.2.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.2.5/Makefile | 6 +- .../atlassian/jira/5/5.2.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.2.5/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.2.6/Makefile | 6 +- .../atlassian/jira/5/5.2.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.2.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.2.7/Makefile | 6 +- .../atlassian/jira/5/5.2.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.2.7/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.2.8/Makefile | 6 +- .../atlassian/jira/5/5.2.8/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.2.8/requirements.txt | 1 + .../ecosystem/atlassian/jira/5/5.2.9/Makefile | 6 +- .../atlassian/jira/5/5.2.9/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.2.9/requirements.txt | 1 + linux/ecosystem/atlassian/jira/5/5.2/Makefile | 6 +- .../atlassian/jira/5/5.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/5/5.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.0.1/Makefile | 6 +- .../atlassian/jira/6/6.0.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.0.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.0.2/Makefile | 6 +- .../atlassian/jira/6/6.0.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.0.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.0.3/Makefile | 6 +- .../atlassian/jira/6/6.0.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.0.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.0.4/Makefile | 6 +- .../atlassian/jira/6/6.0.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.0.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.0.5/Makefile | 6 +- .../atlassian/jira/6/6.0.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.0.5/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.0.6/Makefile | 6 +- .../atlassian/jira/6/6.0.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.0.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.0.7/Makefile | 6 +- .../atlassian/jira/6/6.0.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.0.7/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.0.8/Makefile | 6 +- .../atlassian/jira/6/6.0.8/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.0.8/requirements.txt | 1 + linux/ecosystem/atlassian/jira/6/6.0/Makefile | 6 +- .../atlassian/jira/6/6.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.1.1/Makefile | 6 +- .../atlassian/jira/6/6.1.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.1.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.1.2/Makefile | 6 +- .../atlassian/jira/6/6.1.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.1.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.1.3/Makefile | 6 +- .../atlassian/jira/6/6.1.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.1.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.1.4/Makefile | 6 +- .../atlassian/jira/6/6.1.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.1.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.1.5/Makefile | 6 +- .../atlassian/jira/6/6.1.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.1.5/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.1.6/Makefile | 6 +- .../atlassian/jira/6/6.1.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.1.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.1.7/Makefile | 6 +- .../atlassian/jira/6/6.1.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.1.7/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.1.8/Makefile | 6 +- .../atlassian/jira/6/6.1.8/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.1.8/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.1.9/Makefile | 6 +- .../atlassian/jira/6/6.1.9/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.1.9/requirements.txt | 1 + linux/ecosystem/atlassian/jira/6/6.1/Makefile | 6 +- .../atlassian/jira/6/6.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.2.1/Makefile | 6 +- .../atlassian/jira/6/6.2.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.2.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.2.2/Makefile | 6 +- .../atlassian/jira/6/6.2.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.2.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.2.3/Makefile | 6 +- .../atlassian/jira/6/6.2.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.2.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.2.4/Makefile | 6 +- .../atlassian/jira/6/6.2.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.2.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.2.5/Makefile | 6 +- .../atlassian/jira/6/6.2.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.2.5/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.2.6/Makefile | 6 +- .../atlassian/jira/6/6.2.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.2.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.2.7/Makefile | 6 +- .../atlassian/jira/6/6.2.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.2.7/requirements.txt | 1 + linux/ecosystem/atlassian/jira/6/6.2/Makefile | 6 +- .../atlassian/jira/6/6.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.3.1/Makefile | 6 +- .../atlassian/jira/6/6.3.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.3.1/requirements.txt | 1 + .../atlassian/jira/6/6.3.10/Makefile | 6 +- .../atlassian/jira/6/6.3.10/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.3.10/requirements.txt | 1 + .../atlassian/jira/6/6.3.11/Makefile | 6 +- .../atlassian/jira/6/6.3.11/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.3.11/requirements.txt | 1 + .../atlassian/jira/6/6.3.12/Makefile | 6 +- .../atlassian/jira/6/6.3.12/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.3.12/requirements.txt | 1 + .../atlassian/jira/6/6.3.13/Makefile | 6 +- .../atlassian/jira/6/6.3.13/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.3.13/requirements.txt | 1 + .../atlassian/jira/6/6.3.14/Makefile | 6 +- .../atlassian/jira/6/6.3.14/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.3.14/requirements.txt | 1 + .../atlassian/jira/6/6.3.15/Makefile | 6 +- .../atlassian/jira/6/6.3.15/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.3.15/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.3.3/Makefile | 6 +- .../atlassian/jira/6/6.3.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.3.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.3.4/Makefile | 6 +- .../atlassian/jira/6/6.3.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.3.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.3.5/Makefile | 6 +- .../atlassian/jira/6/6.3.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.3.5/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.3.6/Makefile | 6 +- .../atlassian/jira/6/6.3.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.3.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.3.7/Makefile | 6 +- .../atlassian/jira/6/6.3.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.3.7/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.3.8/Makefile | 6 +- .../atlassian/jira/6/6.3.8/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.3.8/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.3.9/Makefile | 6 +- .../atlassian/jira/6/6.3.9/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.3.9/requirements.txt | 1 + linux/ecosystem/atlassian/jira/6/6.3/Makefile | 6 +- .../atlassian/jira/6/6.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.4.1/Makefile | 6 +- .../atlassian/jira/6/6.4.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.4.1/requirements.txt | 1 + .../atlassian/jira/6/6.4.10/Makefile | 6 +- .../atlassian/jira/6/6.4.10/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.4.10/requirements.txt | 1 + .../atlassian/jira/6/6.4.11/Makefile | 6 +- .../atlassian/jira/6/6.4.11/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.4.11/requirements.txt | 1 + .../atlassian/jira/6/6.4.12/Makefile | 6 +- .../atlassian/jira/6/6.4.12/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.4.12/requirements.txt | 1 + .../atlassian/jira/6/6.4.13/Makefile | 6 +- .../atlassian/jira/6/6.4.13/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.4.13/requirements.txt | 1 + .../atlassian/jira/6/6.4.14/Makefile | 6 +- .../atlassian/jira/6/6.4.14/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.4.14/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.4.2/Makefile | 6 +- .../atlassian/jira/6/6.4.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.4.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.4.3/Makefile | 6 +- .../atlassian/jira/6/6.4.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.4.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.4.4/Makefile | 6 +- .../atlassian/jira/6/6.4.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.4.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.4.5/Makefile | 6 +- .../atlassian/jira/6/6.4.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.4.5/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.4.6/Makefile | 6 +- .../atlassian/jira/6/6.4.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.4.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.4.7/Makefile | 6 +- .../atlassian/jira/6/6.4.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.4.7/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.4.8/Makefile | 6 +- .../atlassian/jira/6/6.4.8/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.4.8/requirements.txt | 1 + .../ecosystem/atlassian/jira/6/6.4.9/Makefile | 6 +- .../atlassian/jira/6/6.4.9/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.4.9/requirements.txt | 1 + linux/ecosystem/atlassian/jira/6/6.4/Makefile | 6 +- .../atlassian/jira/6/6.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/6/6.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.0.0/Makefile | 6 +- .../atlassian/jira/7/7.0.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.0.0/requirements.txt | 1 + .../atlassian/jira/7/7.0.10/Makefile | 6 +- .../atlassian/jira/7/7.0.10/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.0.10/requirements.txt | 1 + .../atlassian/jira/7/7.0.11/Makefile | 6 +- .../atlassian/jira/7/7.0.11/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.0.11/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.0.2/Makefile | 6 +- .../atlassian/jira/7/7.0.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.0.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.0.4/Makefile | 6 +- .../atlassian/jira/7/7.0.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.0.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.0.5/Makefile | 6 +- .../atlassian/jira/7/7.0.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.0.5/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.0.9/Makefile | 6 +- .../atlassian/jira/7/7.0.9/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.0.9/requirements.txt | 1 + .../atlassian/jira/7/7.1.0-m01/Makefile | 6 +- .../jira/7/7.1.0-m01/kaniko-build.py | 196 ------------------ .../jira/7/7.1.0-m01/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.1.0/Makefile | 6 +- .../atlassian/jira/7/7.1.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.1.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.1.1/Makefile | 6 +- .../atlassian/jira/7/7.1.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.1.1/requirements.txt | 1 + .../atlassian/jira/7/7.1.10/Makefile | 6 +- .../atlassian/jira/7/7.1.10/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.1.10/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.1.2/Makefile | 6 +- .../atlassian/jira/7/7.1.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.1.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.1.4/Makefile | 6 +- .../atlassian/jira/7/7.1.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.1.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.1.6/Makefile | 6 +- .../atlassian/jira/7/7.1.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.1.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.1.7/Makefile | 6 +- .../atlassian/jira/7/7.1.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.1.7/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.1.8/Makefile | 6 +- .../atlassian/jira/7/7.1.8/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.1.8/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.1.9/Makefile | 6 +- .../atlassian/jira/7/7.1.9/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.1.9/requirements.txt | 1 + .../atlassian/jira/7/7.10.0/Makefile | 6 +- .../atlassian/jira/7/7.10.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.10.0/requirements.txt | 1 + .../atlassian/jira/7/7.10.1/Makefile | 6 +- .../atlassian/jira/7/7.10.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.10.1/requirements.txt | 1 + .../atlassian/jira/7/7.10.2/Makefile | 6 +- .../atlassian/jira/7/7.10.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.10.2/requirements.txt | 1 + .../atlassian/jira/7/7.11.0/Makefile | 6 +- .../atlassian/jira/7/7.11.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.11.0/requirements.txt | 1 + .../atlassian/jira/7/7.11.1/Makefile | 6 +- .../atlassian/jira/7/7.11.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.11.1/requirements.txt | 1 + .../atlassian/jira/7/7.11.2/Makefile | 6 +- .../atlassian/jira/7/7.11.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.11.2/requirements.txt | 1 + .../atlassian/jira/7/7.12.0/Makefile | 6 +- .../atlassian/jira/7/7.12.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.12.0/requirements.txt | 1 + .../atlassian/jira/7/7.12.1/Makefile | 6 +- .../atlassian/jira/7/7.12.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.12.1/requirements.txt | 1 + .../atlassian/jira/7/7.12.3/Makefile | 6 +- .../atlassian/jira/7/7.12.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.12.3/requirements.txt | 1 + .../atlassian/jira/7/7.13.0/Makefile | 6 +- .../atlassian/jira/7/7.13.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.0/requirements.txt | 1 + .../atlassian/jira/7/7.13.1/Makefile | 6 +- .../atlassian/jira/7/7.13.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.1/requirements.txt | 1 + .../atlassian/jira/7/7.13.11/Makefile | 6 +- .../atlassian/jira/7/7.13.11/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.11/requirements.txt | 1 + .../atlassian/jira/7/7.13.12/Makefile | 6 +- .../atlassian/jira/7/7.13.12/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.12/requirements.txt | 1 + .../atlassian/jira/7/7.13.13/Makefile | 6 +- .../atlassian/jira/7/7.13.13/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.13/requirements.txt | 1 + .../atlassian/jira/7/7.13.14/Makefile | 6 +- .../atlassian/jira/7/7.13.14/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.14/requirements.txt | 1 + .../atlassian/jira/7/7.13.15/Makefile | 6 +- .../atlassian/jira/7/7.13.15/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.15/requirements.txt | 1 + .../atlassian/jira/7/7.13.16/Makefile | 6 +- .../atlassian/jira/7/7.13.16/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.16/requirements.txt | 1 + .../atlassian/jira/7/7.13.17/Makefile | 6 +- .../atlassian/jira/7/7.13.17/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.17/requirements.txt | 1 + .../atlassian/jira/7/7.13.18/Makefile | 6 +- .../atlassian/jira/7/7.13.18/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.18/requirements.txt | 1 + .../atlassian/jira/7/7.13.2/Makefile | 6 +- .../atlassian/jira/7/7.13.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.2/requirements.txt | 1 + .../atlassian/jira/7/7.13.3/Makefile | 6 +- .../atlassian/jira/7/7.13.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.3/requirements.txt | 1 + .../atlassian/jira/7/7.13.4/Makefile | 6 +- .../atlassian/jira/7/7.13.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.4/requirements.txt | 1 + .../atlassian/jira/7/7.13.5/Makefile | 6 +- .../atlassian/jira/7/7.13.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.5/requirements.txt | 1 + .../atlassian/jira/7/7.13.6/Makefile | 6 +- .../atlassian/jira/7/7.13.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.6/requirements.txt | 1 + .../atlassian/jira/7/7.13.8/Makefile | 6 +- .../atlassian/jira/7/7.13.8/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.8/requirements.txt | 1 + .../atlassian/jira/7/7.13.9/Makefile | 6 +- .../atlassian/jira/7/7.13.9/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.13.9/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.2.0/Makefile | 6 +- .../atlassian/jira/7/7.2.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.2.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.2.1/Makefile | 6 +- .../atlassian/jira/7/7.2.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.2.1/requirements.txt | 1 + .../atlassian/jira/7/7.2.10/Makefile | 6 +- .../atlassian/jira/7/7.2.10/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.2.10/requirements.txt | 1 + .../atlassian/jira/7/7.2.11/Makefile | 6 +- .../atlassian/jira/7/7.2.11/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.2.11/requirements.txt | 1 + .../atlassian/jira/7/7.2.12/Makefile | 6 +- .../atlassian/jira/7/7.2.12/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.2.12/requirements.txt | 1 + .../atlassian/jira/7/7.2.13/Makefile | 6 +- .../atlassian/jira/7/7.2.13/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.2.13/requirements.txt | 1 + .../atlassian/jira/7/7.2.14/Makefile | 6 +- .../atlassian/jira/7/7.2.14/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.2.14/requirements.txt | 1 + .../atlassian/jira/7/7.2.15/Makefile | 6 +- .../atlassian/jira/7/7.2.15/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.2.15/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.2.2/Makefile | 6 +- .../atlassian/jira/7/7.2.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.2.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.2.3/Makefile | 6 +- .../atlassian/jira/7/7.2.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.2.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.2.4/Makefile | 6 +- .../atlassian/jira/7/7.2.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.2.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.2.6/Makefile | 6 +- .../atlassian/jira/7/7.2.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.2.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.2.7/Makefile | 6 +- .../atlassian/jira/7/7.2.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.2.7/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.2.8/Makefile | 6 +- .../atlassian/jira/7/7.2.8/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.2.8/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.2.9/Makefile | 6 +- .../atlassian/jira/7/7.2.9/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.2.9/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.3.0/Makefile | 6 +- .../atlassian/jira/7/7.3.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.3.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.3.1/Makefile | 6 +- .../atlassian/jira/7/7.3.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.3.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.3.2/Makefile | 6 +- .../atlassian/jira/7/7.3.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.3.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.3.3/Makefile | 6 +- .../atlassian/jira/7/7.3.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.3.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.3.4/Makefile | 6 +- .../atlassian/jira/7/7.3.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.3.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.3.5/Makefile | 6 +- .../atlassian/jira/7/7.3.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.3.5/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.3.6/Makefile | 6 +- .../atlassian/jira/7/7.3.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.3.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.3.7/Makefile | 6 +- .../atlassian/jira/7/7.3.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.3.7/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.3.8/Makefile | 6 +- .../atlassian/jira/7/7.3.8/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.3.8/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.3.9/Makefile | 6 +- .../atlassian/jira/7/7.3.9/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.3.9/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.4.0/Makefile | 6 +- .../atlassian/jira/7/7.4.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.4.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.4.1/Makefile | 6 +- .../atlassian/jira/7/7.4.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.4.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.4.2/Makefile | 6 +- .../atlassian/jira/7/7.4.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.4.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.4.3/Makefile | 6 +- .../atlassian/jira/7/7.4.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.4.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.4.4/Makefile | 6 +- .../atlassian/jira/7/7.4.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.4.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.4.5/Makefile | 6 +- .../atlassian/jira/7/7.4.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.4.5/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.4.6/Makefile | 6 +- .../atlassian/jira/7/7.4.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.4.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.5.0/Makefile | 6 +- .../atlassian/jira/7/7.5.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.5.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.5.1/Makefile | 6 +- .../atlassian/jira/7/7.5.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.5.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.5.2/Makefile | 6 +- .../atlassian/jira/7/7.5.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.5.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.5.3/Makefile | 6 +- .../atlassian/jira/7/7.5.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.5.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.5.4/Makefile | 6 +- .../atlassian/jira/7/7.5.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.5.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.6.0/Makefile | 6 +- .../atlassian/jira/7/7.6.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.6.1/Makefile | 6 +- .../atlassian/jira/7/7.6.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.1/requirements.txt | 1 + .../atlassian/jira/7/7.6.10/Makefile | 6 +- .../atlassian/jira/7/7.6.10/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.10/requirements.txt | 1 + .../atlassian/jira/7/7.6.11/Makefile | 6 +- .../atlassian/jira/7/7.6.11/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.11/requirements.txt | 1 + .../atlassian/jira/7/7.6.12/Makefile | 6 +- .../atlassian/jira/7/7.6.12/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.12/requirements.txt | 1 + .../atlassian/jira/7/7.6.13/Makefile | 6 +- .../atlassian/jira/7/7.6.13/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.13/requirements.txt | 1 + .../atlassian/jira/7/7.6.14/Makefile | 6 +- .../atlassian/jira/7/7.6.14/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.14/requirements.txt | 1 + .../atlassian/jira/7/7.6.15/Makefile | 6 +- .../atlassian/jira/7/7.6.15/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.15/requirements.txt | 1 + .../atlassian/jira/7/7.6.16/Makefile | 6 +- .../atlassian/jira/7/7.6.16/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.16/requirements.txt | 1 + .../atlassian/jira/7/7.6.17/Makefile | 6 +- .../atlassian/jira/7/7.6.17/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.17/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.6.2/Makefile | 6 +- .../atlassian/jira/7/7.6.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.6.3/Makefile | 6 +- .../atlassian/jira/7/7.6.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.6.4/Makefile | 6 +- .../atlassian/jira/7/7.6.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.6.6/Makefile | 6 +- .../atlassian/jira/7/7.6.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.6.7/Makefile | 6 +- .../atlassian/jira/7/7.6.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.7/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.6.8/Makefile | 6 +- .../atlassian/jira/7/7.6.8/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.8/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.6.9/Makefile | 6 +- .../atlassian/jira/7/7.6.9/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.6.9/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.7.0/Makefile | 6 +- .../atlassian/jira/7/7.7.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.7.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.7.1/Makefile | 6 +- .../atlassian/jira/7/7.7.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.7.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.7.2/Makefile | 6 +- .../atlassian/jira/7/7.7.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.7.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.7.4/Makefile | 6 +- .../atlassian/jira/7/7.7.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.7.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.8.0/Makefile | 6 +- .../atlassian/jira/7/7.8.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.8.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.8.1/Makefile | 6 +- .../atlassian/jira/7/7.8.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.8.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.8.2/Makefile | 6 +- .../atlassian/jira/7/7.8.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.8.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.8.4/Makefile | 6 +- .../atlassian/jira/7/7.8.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.8.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.9.0/Makefile | 6 +- .../atlassian/jira/7/7.9.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.9.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/7/7.9.2/Makefile | 6 +- .../atlassian/jira/7/7.9.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/7/7.9.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.0.0/Makefile | 6 +- .../atlassian/jira/8/8.0.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.0.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.0.2/Makefile | 6 +- .../atlassian/jira/8/8.0.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.0.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.0.3/Makefile | 6 +- .../atlassian/jira/8/8.0.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.0.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.1.0/Makefile | 6 +- .../atlassian/jira/8/8.1.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.1.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.1.1/Makefile | 6 +- .../atlassian/jira/8/8.1.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.1.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.1.2/Makefile | 6 +- .../atlassian/jira/8/8.1.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.1.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.1.3/Makefile | 6 +- .../atlassian/jira/8/8.1.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.1.3/requirements.txt | 1 + .../atlassian/jira/8/8.10.0/Makefile | 6 +- .../atlassian/jira/8/8.10.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.10.0/requirements.txt | 1 + .../atlassian/jira/8/8.10.1/Makefile | 6 +- .../atlassian/jira/8/8.10.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.10.1/requirements.txt | 1 + .../atlassian/jira/8/8.11.0/Makefile | 6 +- .../atlassian/jira/8/8.11.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.11.0/requirements.txt | 1 + .../atlassian/jira/8/8.11.1/Makefile | 6 +- .../atlassian/jira/8/8.11.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.11.1/requirements.txt | 1 + .../atlassian/jira/8/8.12.0/Makefile | 6 +- .../atlassian/jira/8/8.12.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.12.0/requirements.txt | 1 + .../atlassian/jira/8/8.12.1/Makefile | 6 +- .../atlassian/jira/8/8.12.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.12.1/requirements.txt | 1 + .../atlassian/jira/8/8.12.2/Makefile | 6 +- .../atlassian/jira/8/8.12.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.12.2/requirements.txt | 1 + .../atlassian/jira/8/8.12.3/Makefile | 6 +- .../atlassian/jira/8/8.12.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.12.3/requirements.txt | 1 + .../atlassian/jira/8/8.13.0/Makefile | 6 +- .../atlassian/jira/8/8.13.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.0/requirements.txt | 1 + .../atlassian/jira/8/8.13.1/Makefile | 6 +- .../atlassian/jira/8/8.13.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.1/requirements.txt | 1 + .../atlassian/jira/8/8.13.10/Makefile | 6 +- .../atlassian/jira/8/8.13.10/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.10/requirements.txt | 1 + .../atlassian/jira/8/8.13.11/Makefile | 6 +- .../atlassian/jira/8/8.13.11/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.11/requirements.txt | 1 + .../atlassian/jira/8/8.13.12/Makefile | 6 +- .../atlassian/jira/8/8.13.12/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.12/requirements.txt | 1 + .../atlassian/jira/8/8.13.13/Makefile | 6 +- .../atlassian/jira/8/8.13.13/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.13/requirements.txt | 1 + .../atlassian/jira/8/8.13.14/Makefile | 6 +- .../atlassian/jira/8/8.13.14/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.14/requirements.txt | 1 + .../atlassian/jira/8/8.13.15/Makefile | 6 +- .../atlassian/jira/8/8.13.15/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.15/requirements.txt | 1 + .../atlassian/jira/8/8.13.16/Makefile | 6 +- .../atlassian/jira/8/8.13.16/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.16/requirements.txt | 1 + .../atlassian/jira/8/8.13.17/Makefile | 6 +- .../atlassian/jira/8/8.13.17/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.17/requirements.txt | 1 + .../atlassian/jira/8/8.13.18/Makefile | 6 +- .../atlassian/jira/8/8.13.18/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.18/requirements.txt | 1 + .../atlassian/jira/8/8.13.19/Makefile | 6 +- .../atlassian/jira/8/8.13.19/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.19/requirements.txt | 1 + .../atlassian/jira/8/8.13.2/Makefile | 6 +- .../atlassian/jira/8/8.13.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.2/requirements.txt | 1 + .../atlassian/jira/8/8.13.20/Makefile | 6 +- .../atlassian/jira/8/8.13.20/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.20/requirements.txt | 1 + .../atlassian/jira/8/8.13.21/Makefile | 6 +- .../atlassian/jira/8/8.13.21/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.21/requirements.txt | 1 + .../atlassian/jira/8/8.13.22/Makefile | 6 +- .../atlassian/jira/8/8.13.22/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.22/requirements.txt | 1 + .../atlassian/jira/8/8.13.24/Makefile | 6 +- .../atlassian/jira/8/8.13.24/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.24/requirements.txt | 1 + .../atlassian/jira/8/8.13.25/Makefile | 6 +- .../atlassian/jira/8/8.13.25/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.25/requirements.txt | 1 + .../atlassian/jira/8/8.13.26/Makefile | 6 +- .../atlassian/jira/8/8.13.26/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.26/requirements.txt | 1 + .../atlassian/jira/8/8.13.27/Makefile | 6 +- .../atlassian/jira/8/8.13.27/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.27/requirements.txt | 1 + .../atlassian/jira/8/8.13.3/Makefile | 6 +- .../atlassian/jira/8/8.13.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.3/requirements.txt | 1 + .../atlassian/jira/8/8.13.4/Makefile | 6 +- .../atlassian/jira/8/8.13.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.4/requirements.txt | 1 + .../atlassian/jira/8/8.13.5/Makefile | 6 +- .../atlassian/jira/8/8.13.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.5/requirements.txt | 1 + .../atlassian/jira/8/8.13.6/Makefile | 6 +- .../atlassian/jira/8/8.13.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.6/requirements.txt | 1 + .../atlassian/jira/8/8.13.7/Makefile | 6 +- .../atlassian/jira/8/8.13.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.7/requirements.txt | 1 + .../atlassian/jira/8/8.13.8/Makefile | 6 +- .../atlassian/jira/8/8.13.8/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.8/requirements.txt | 1 + .../atlassian/jira/8/8.13.9/Makefile | 6 +- .../atlassian/jira/8/8.13.9/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.13.9/requirements.txt | 1 + .../atlassian/jira/8/8.14.0/Makefile | 6 +- .../atlassian/jira/8/8.14.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.14.0/requirements.txt | 1 + .../atlassian/jira/8/8.14.1/Makefile | 6 +- .../atlassian/jira/8/8.14.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.14.1/requirements.txt | 1 + .../atlassian/jira/8/8.15.0/Makefile | 6 +- .../atlassian/jira/8/8.15.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.15.0/requirements.txt | 1 + .../atlassian/jira/8/8.15.1/Makefile | 6 +- .../atlassian/jira/8/8.15.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.15.1/requirements.txt | 1 + .../atlassian/jira/8/8.16.0/Makefile | 6 +- .../atlassian/jira/8/8.16.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.16.0/requirements.txt | 1 + .../atlassian/jira/8/8.16.1/Makefile | 6 +- .../atlassian/jira/8/8.16.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.16.1/requirements.txt | 1 + .../atlassian/jira/8/8.16.2/Makefile | 6 +- .../atlassian/jira/8/8.16.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.16.2/requirements.txt | 1 + .../atlassian/jira/8/8.17.0/Makefile | 6 +- .../atlassian/jira/8/8.17.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.17.0/requirements.txt | 1 + .../atlassian/jira/8/8.17.1/Makefile | 6 +- .../atlassian/jira/8/8.17.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.17.1/requirements.txt | 1 + .../atlassian/jira/8/8.18.1/Makefile | 6 +- .../atlassian/jira/8/8.18.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.18.1/requirements.txt | 1 + .../atlassian/jira/8/8.18.2/Makefile | 6 +- .../atlassian/jira/8/8.18.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.18.2/requirements.txt | 1 + .../atlassian/jira/8/8.19.0/Makefile | 6 +- .../atlassian/jira/8/8.19.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.19.0/requirements.txt | 1 + .../atlassian/jira/8/8.19.1/Makefile | 6 +- .../atlassian/jira/8/8.19.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.19.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.2.0/Makefile | 6 +- .../atlassian/jira/8/8.2.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.2.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.2.1/Makefile | 6 +- .../atlassian/jira/8/8.2.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.2.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.2.2/Makefile | 6 +- .../atlassian/jira/8/8.2.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.2.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.2.3/Makefile | 6 +- .../atlassian/jira/8/8.2.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.2.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.2.4/Makefile | 6 +- .../atlassian/jira/8/8.2.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.2.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.2.5/Makefile | 6 +- .../atlassian/jira/8/8.2.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.2.5/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.2.6/Makefile | 6 +- .../atlassian/jira/8/8.2.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.2.6/requirements.txt | 1 + .../atlassian/jira/8/8.20.0/Makefile | 6 +- .../atlassian/jira/8/8.20.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.0/requirements.txt | 1 + .../atlassian/jira/8/8.20.1/Makefile | 6 +- .../atlassian/jira/8/8.20.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.1/requirements.txt | 1 + .../atlassian/jira/8/8.20.10/Makefile | 6 +- .../atlassian/jira/8/8.20.10/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.10/requirements.txt | 1 + .../atlassian/jira/8/8.20.11/Makefile | 6 +- .../atlassian/jira/8/8.20.11/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.11/requirements.txt | 1 + .../atlassian/jira/8/8.20.12/Makefile | 6 +- .../atlassian/jira/8/8.20.12/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.12/requirements.txt | 1 + .../atlassian/jira/8/8.20.13/Makefile | 6 +- .../atlassian/jira/8/8.20.13/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.13/requirements.txt | 1 + .../atlassian/jira/8/8.20.14/Makefile | 6 +- .../atlassian/jira/8/8.20.14/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.14/requirements.txt | 1 + .../atlassian/jira/8/8.20.15/Makefile | 6 +- .../atlassian/jira/8/8.20.15/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.15/requirements.txt | 1 + .../atlassian/jira/8/8.20.16/Makefile | 6 +- .../atlassian/jira/8/8.20.16/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.16/requirements.txt | 1 + .../atlassian/jira/8/8.20.17/Makefile | 6 +- .../atlassian/jira/8/8.20.17/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.17/requirements.txt | 1 + .../atlassian/jira/8/8.20.19/Makefile | 6 +- .../atlassian/jira/8/8.20.19/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.19/requirements.txt | 1 + .../atlassian/jira/8/8.20.2/Makefile | 6 +- .../atlassian/jira/8/8.20.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.2/requirements.txt | 1 + .../atlassian/jira/8/8.20.20/Makefile | 6 +- .../atlassian/jira/8/8.20.20/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.20/requirements.txt | 1 + .../atlassian/jira/8/8.20.21/Makefile | 6 +- .../atlassian/jira/8/8.20.21/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.21/requirements.txt | 1 + .../atlassian/jira/8/8.20.22/Makefile | 6 +- .../atlassian/jira/8/8.20.22/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.22/requirements.txt | 1 + .../atlassian/jira/8/8.20.23/Makefile | 6 +- .../atlassian/jira/8/8.20.23/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.23/requirements.txt | 1 + .../atlassian/jira/8/8.20.24/Makefile | 6 +- .../atlassian/jira/8/8.20.24/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.24/requirements.txt | 1 + .../atlassian/jira/8/8.20.25/Makefile | 6 +- .../atlassian/jira/8/8.20.25/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.25/requirements.txt | 1 + .../atlassian/jira/8/8.20.26/Makefile | 6 +- .../atlassian/jira/8/8.20.26/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.26/requirements.txt | 1 + .../atlassian/jira/8/8.20.27/Makefile | 6 +- .../atlassian/jira/8/8.20.27/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.27/requirements.txt | 1 + .../atlassian/jira/8/8.20.28/Makefile | 6 +- .../atlassian/jira/8/8.20.28/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.28/requirements.txt | 1 + .../atlassian/jira/8/8.20.29/Makefile | 6 +- .../atlassian/jira/8/8.20.29/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.29/requirements.txt | 1 + .../atlassian/jira/8/8.20.3/Makefile | 6 +- .../atlassian/jira/8/8.20.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.3/requirements.txt | 1 + .../atlassian/jira/8/8.20.30/Makefile | 6 +- .../atlassian/jira/8/8.20.30/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.30/requirements.txt | 1 + .../atlassian/jira/8/8.20.4/Makefile | 6 +- .../atlassian/jira/8/8.20.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.4/requirements.txt | 1 + .../atlassian/jira/8/8.20.5/Makefile | 6 +- .../atlassian/jira/8/8.20.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.5/requirements.txt | 1 + .../atlassian/jira/8/8.20.6/Makefile | 6 +- .../atlassian/jira/8/8.20.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.6/requirements.txt | 1 + .../atlassian/jira/8/8.20.7/Makefile | 6 +- .../atlassian/jira/8/8.20.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.7/requirements.txt | 1 + .../atlassian/jira/8/8.20.8/Makefile | 6 +- .../atlassian/jira/8/8.20.8/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.8/requirements.txt | 1 + .../atlassian/jira/8/8.20.9/Makefile | 6 +- .../atlassian/jira/8/8.20.9/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.20.9/requirements.txt | 1 + .../atlassian/jira/8/8.21.0/Makefile | 6 +- .../atlassian/jira/8/8.21.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.21.0/requirements.txt | 1 + .../atlassian/jira/8/8.21.1/Makefile | 6 +- .../atlassian/jira/8/8.21.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.21.1/requirements.txt | 1 + .../atlassian/jira/8/8.22.0/Makefile | 6 +- .../atlassian/jira/8/8.22.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.22.0/requirements.txt | 1 + .../atlassian/jira/8/8.22.1/Makefile | 6 +- .../atlassian/jira/8/8.22.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.22.1/requirements.txt | 1 + .../atlassian/jira/8/8.22.2/Makefile | 6 +- .../atlassian/jira/8/8.22.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.22.2/requirements.txt | 1 + .../atlassian/jira/8/8.22.3/Makefile | 6 +- .../atlassian/jira/8/8.22.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.22.3/requirements.txt | 1 + .../atlassian/jira/8/8.22.4/Makefile | 6 +- .../atlassian/jira/8/8.22.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.22.4/requirements.txt | 1 + .../atlassian/jira/8/8.22.5/Makefile | 6 +- .../atlassian/jira/8/8.22.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.22.5/requirements.txt | 1 + .../atlassian/jira/8/8.22.6/Makefile | 6 +- .../atlassian/jira/8/8.22.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.22.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.3.0/Makefile | 6 +- .../atlassian/jira/8/8.3.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.3.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.3.1/Makefile | 6 +- .../atlassian/jira/8/8.3.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.3.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.3.2/Makefile | 6 +- .../atlassian/jira/8/8.3.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.3.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.3.3/Makefile | 6 +- .../atlassian/jira/8/8.3.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.3.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.3.4/Makefile | 6 +- .../atlassian/jira/8/8.3.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.3.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.3.5/Makefile | 6 +- .../atlassian/jira/8/8.3.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.3.5/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.4.0/Makefile | 6 +- .../atlassian/jira/8/8.4.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.4.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.4.1/Makefile | 6 +- .../atlassian/jira/8/8.4.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.4.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.4.2/Makefile | 6 +- .../atlassian/jira/8/8.4.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.4.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.4.3/Makefile | 6 +- .../atlassian/jira/8/8.4.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.4.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.5.0/Makefile | 6 +- .../atlassian/jira/8/8.5.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.5.1/Makefile | 6 +- .../atlassian/jira/8/8.5.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.1/requirements.txt | 1 + .../atlassian/jira/8/8.5.10/Makefile | 6 +- .../atlassian/jira/8/8.5.10/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.10/requirements.txt | 1 + .../atlassian/jira/8/8.5.11/Makefile | 6 +- .../atlassian/jira/8/8.5.11/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.11/requirements.txt | 1 + .../atlassian/jira/8/8.5.12/Makefile | 6 +- .../atlassian/jira/8/8.5.12/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.12/requirements.txt | 1 + .../atlassian/jira/8/8.5.13/Makefile | 6 +- .../atlassian/jira/8/8.5.13/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.13/requirements.txt | 1 + .../atlassian/jira/8/8.5.14/Makefile | 6 +- .../atlassian/jira/8/8.5.14/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.14/requirements.txt | 1 + .../atlassian/jira/8/8.5.15/Makefile | 6 +- .../atlassian/jira/8/8.5.15/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.15/requirements.txt | 1 + .../atlassian/jira/8/8.5.16/Makefile | 6 +- .../atlassian/jira/8/8.5.16/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.16/requirements.txt | 1 + .../atlassian/jira/8/8.5.17/Makefile | 6 +- .../atlassian/jira/8/8.5.17/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.17/requirements.txt | 1 + .../atlassian/jira/8/8.5.18/Makefile | 6 +- .../atlassian/jira/8/8.5.18/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.18/requirements.txt | 1 + .../atlassian/jira/8/8.5.19/Makefile | 6 +- .../atlassian/jira/8/8.5.19/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.19/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.5.2/Makefile | 6 +- .../atlassian/jira/8/8.5.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.5.3/Makefile | 6 +- .../atlassian/jira/8/8.5.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.5.4/Makefile | 6 +- .../atlassian/jira/8/8.5.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.5.5/Makefile | 6 +- .../atlassian/jira/8/8.5.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.5/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.5.6/Makefile | 6 +- .../atlassian/jira/8/8.5.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.5.7/Makefile | 6 +- .../atlassian/jira/8/8.5.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.7/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.5.8/Makefile | 6 +- .../atlassian/jira/8/8.5.8/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.8/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.5.9/Makefile | 6 +- .../atlassian/jira/8/8.5.9/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.5.9/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.6.0/Makefile | 6 +- .../atlassian/jira/8/8.6.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.6.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.6.1/Makefile | 6 +- .../atlassian/jira/8/8.6.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.6.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.7.0/Makefile | 6 +- .../atlassian/jira/8/8.7.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.7.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.7.1/Makefile | 6 +- .../atlassian/jira/8/8.7.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.7.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.8.0/Makefile | 6 +- .../atlassian/jira/8/8.8.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.8.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.8.1/Makefile | 6 +- .../atlassian/jira/8/8.8.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.8.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.9.0/Makefile | 6 +- .../atlassian/jira/8/8.9.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.9.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/8/8.9.1/Makefile | 6 +- .../atlassian/jira/8/8.9.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/8/8.9.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.0.0/Makefile | 6 +- .../atlassian/jira/9/9.0.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.0.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.1.0/Makefile | 6 +- .../atlassian/jira/9/9.1.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.1.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.1.1/Makefile | 6 +- .../atlassian/jira/9/9.1.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.1.1/requirements.txt | 1 + .../atlassian/jira/9/9.10.0/Makefile | 6 +- .../atlassian/jira/9/9.10.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.10.0/requirements.txt | 1 + .../atlassian/jira/9/9.10.1/Makefile | 6 +- .../atlassian/jira/9/9.10.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.10.1/requirements.txt | 1 + .../atlassian/jira/9/9.10.2/Makefile | 6 +- .../atlassian/jira/9/9.10.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.10.2/requirements.txt | 1 + .../atlassian/jira/9/9.11.0/Makefile | 6 +- .../atlassian/jira/9/9.11.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.11.0/requirements.txt | 1 + .../atlassian/jira/9/9.11.1/Makefile | 6 +- .../atlassian/jira/9/9.11.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.11.1/requirements.txt | 1 + .../atlassian/jira/9/9.11.2/Makefile | 6 +- .../atlassian/jira/9/9.11.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.11.2/requirements.txt | 1 + .../atlassian/jira/9/9.11.3/Makefile | 6 +- .../atlassian/jira/9/9.11.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.11.3/requirements.txt | 1 + .../atlassian/jira/9/9.12.0/Makefile | 6 +- .../atlassian/jira/9/9.12.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.12.0/requirements.txt | 1 + .../atlassian/jira/9/9.12.1/Makefile | 6 +- .../atlassian/jira/9/9.12.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.12.1/requirements.txt | 1 + .../atlassian/jira/9/9.12.12/Makefile | 6 +- .../atlassian/jira/9/9.12.12/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.12.12/requirements.txt | 1 + .../atlassian/jira/9/9.12.2/Makefile | 6 +- .../atlassian/jira/9/9.12.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.12.2/requirements.txt | 1 + .../atlassian/jira/9/9.14.1/Makefile | 6 +- .../atlassian/jira/9/9.14.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.14.1/requirements.txt | 1 + .../atlassian/jira/9/9.16.1/Makefile | 6 +- .../atlassian/jira/9/9.16.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.16.1/requirements.txt | 1 + .../atlassian/jira/9/9.17.1/Makefile | 6 +- .../atlassian/jira/9/9.17.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.17.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.2.0/Makefile | 6 +- .../atlassian/jira/9/9.2.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.2.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.2.1/Makefile | 6 +- .../atlassian/jira/9/9.2.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.2.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.3.0/Makefile | 6 +- .../atlassian/jira/9/9.3.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.3.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.3.1/Makefile | 6 +- .../atlassian/jira/9/9.3.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.3.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.3.2/Makefile | 6 +- .../atlassian/jira/9/9.3.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.3.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.3.3/Makefile | 6 +- .../atlassian/jira/9/9.3.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.3.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.4.0/Makefile | 6 +- .../atlassian/jira/9/9.4.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.4.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.4.1/Makefile | 6 +- .../atlassian/jira/9/9.4.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.4.1/requirements.txt | 1 + .../atlassian/jira/9/9.4.10/Makefile | 6 +- .../atlassian/jira/9/9.4.10/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.4.10/requirements.txt | 1 + .../atlassian/jira/9/9.4.11/Makefile | 6 +- .../atlassian/jira/9/9.4.11/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.4.11/requirements.txt | 1 + .../atlassian/jira/9/9.4.12/Makefile | 6 +- .../atlassian/jira/9/9.4.12/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.4.12/requirements.txt | 1 + .../atlassian/jira/9/9.4.14/Makefile | 6 +- .../atlassian/jira/9/9.4.14/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.4.14/requirements.txt | 1 + .../atlassian/jira/9/9.4.15/Makefile | 6 +- .../atlassian/jira/9/9.4.15/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.4.15/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.4.2/Makefile | 6 +- .../atlassian/jira/9/9.4.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.4.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.4.3/Makefile | 6 +- .../atlassian/jira/9/9.4.3/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.4.3/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.4.4/Makefile | 6 +- .../atlassian/jira/9/9.4.4/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.4.4/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.4.5/Makefile | 6 +- .../atlassian/jira/9/9.4.5/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.4.5/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.4.6/Makefile | 6 +- .../atlassian/jira/9/9.4.6/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.4.6/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.4.7/Makefile | 6 +- .../atlassian/jira/9/9.4.7/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.4.7/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.4.8/Makefile | 6 +- .../atlassian/jira/9/9.4.8/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.4.8/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.4.9/Makefile | 6 +- .../atlassian/jira/9/9.4.9/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.4.9/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.5.0/Makefile | 6 +- .../atlassian/jira/9/9.5.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.5.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.5.1/Makefile | 6 +- .../atlassian/jira/9/9.5.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.5.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.6.0/Makefile | 6 +- .../atlassian/jira/9/9.6.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.6.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.7.0/Makefile | 6 +- .../atlassian/jira/9/9.7.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.7.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.7.1/Makefile | 6 +- .../atlassian/jira/9/9.7.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.7.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.7.2/Makefile | 6 +- .../atlassian/jira/9/9.7.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.7.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.8.0/Makefile | 6 +- .../atlassian/jira/9/9.8.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.8.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.8.1/Makefile | 6 +- .../atlassian/jira/9/9.8.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.8.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.8.2/Makefile | 6 +- .../atlassian/jira/9/9.8.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.8.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.9.0/Makefile | 6 +- .../atlassian/jira/9/9.9.0/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.9.0/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.9.1/Makefile | 6 +- .../atlassian/jira/9/9.9.1/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.9.1/requirements.txt | 1 + .../ecosystem/atlassian/jira/9/9.9.2/Makefile | 6 +- .../atlassian/jira/9/9.9.2/kaniko-build.py | 196 ------------------ .../atlassian/jira/9/9.9.2/requirements.txt | 1 + .../ecosystem/atlassian/jira/latest/Makefile | 6 +- .../atlassian/jira/latest/kaniko-build.py | 196 ------------------ .../atlassian/jira/latest/requirements.txt | 1 + linux/ecosystem/cassandra/3.11/Makefile | 6 +- .../ecosystem/cassandra/3.11/kaniko-build.py | 196 ------------------ .../ecosystem/cassandra/3.11/requirements.txt | 1 + .../electron-release-server/Makefile | 6 +- .../electron-release-server/kaniko-build.py | 196 ------------------ .../electron-release-server/requirements.txt | 1 + .../epicmorg/astra/1.7-alse/develop/Makefile | 6 +- .../astra/1.7-alse/develop/kaniko-build.py | 196 ------------------ .../astra/1.7-alse/develop/requirements.txt | 1 + .../epicmorg/astra/1.7-alse/jdk11/Makefile | 6 +- .../astra/1.7-alse/jdk11/kaniko-build.py | 196 ------------------ .../astra/1.7-alse/jdk11/requirements.txt | 1 + .../epicmorg/astra/1.7-alse/jdk16/Makefile | 6 +- .../astra/1.7-alse/jdk16/kaniko-build.py | 196 ------------------ .../astra/1.7-alse/jdk16/requirements.txt | 1 + .../epicmorg/astra/1.7-alse/jdk17/Makefile | 6 +- .../astra/1.7-alse/jdk17/kaniko-build.py | 196 ------------------ .../astra/1.7-alse/jdk17/requirements.txt | 1 + .../epicmorg/astra/1.7-alse/jdk18/Makefile | 6 +- .../astra/1.7-alse/jdk18/kaniko-build.py | 196 ------------------ .../astra/1.7-alse/jdk18/requirements.txt | 1 + .../epicmorg/astra/1.7-alse/jdk19/Makefile | 6 +- .../astra/1.7-alse/jdk19/kaniko-build.py | 196 ------------------ .../astra/1.7-alse/jdk19/requirements.txt | 1 + .../epicmorg/astra/1.7-alse/jdk20/Makefile | 6 +- .../astra/1.7-alse/jdk20/kaniko-build.py | 196 ------------------ .../astra/1.7-alse/jdk20/requirements.txt | 1 + .../epicmorg/astra/1.7-alse/jdk21/Makefile | 6 +- .../astra/1.7-alse/jdk21/kaniko-build.py | 196 ------------------ .../astra/1.7-alse/jdk21/requirements.txt | 1 + .../epicmorg/astra/1.7-alse/jdk22/Makefile | 6 +- .../astra/1.7-alse/jdk22/kaniko-build.py | 196 ------------------ .../astra/1.7-alse/jdk22/requirements.txt | 1 + .../epicmorg/astra/1.7-alse/jdk6/Makefile | 6 +- .../astra/1.7-alse/jdk6/kaniko-build.py | 196 ------------------ .../astra/1.7-alse/jdk6/requirements.txt | 1 + .../epicmorg/astra/1.7-alse/jdk7/Makefile | 6 +- .../astra/1.7-alse/jdk7/kaniko-build.py | 196 ------------------ .../astra/1.7-alse/jdk7/requirements.txt | 1 + .../epicmorg/astra/1.7-alse/jdk8/Makefile | 6 +- .../astra/1.7-alse/jdk8/kaniko-build.py | 196 ------------------ .../astra/1.7-alse/jdk8/requirements.txt | 1 + .../epicmorg/astra/1.7-alse/main/Makefile | 6 +- .../astra/1.7-alse/main/kaniko-build.py | 196 ------------------ .../astra/1.7-alse/main/requirements.txt | 1 + .../astra/1.7-alse/python3.10/Makefile | 6 +- .../astra/1.7-alse/python3.10/kaniko-build.py | 196 ------------------ .../1.7-alse/python3.10/requirements.txt | 1 + .../astra/1.7-alse/python3.11/Makefile | 6 +- .../astra/1.7-alse/python3.11/kaniko-build.py | 196 ------------------ .../1.7-alse/python3.11/requirements.txt | 1 + .../astra/1.7-alse/python3.12/Makefile | 6 +- .../astra/1.7-alse/python3.12/kaniko-build.py | 196 ------------------ .../1.7-alse/python3.12/requirements.txt | 1 + .../astra/1.7-alse/python3.13/Makefile | 6 +- .../astra/1.7-alse/python3.13/kaniko-build.py | 196 ------------------ .../1.7-alse/python3.13/requirements.txt | 1 + .../epicmorg/astra/1.7-alse/slim/Makefile | 6 +- .../astra/1.7-alse/slim/kaniko-build.py | 196 ------------------ .../astra/1.7-alse/slim/requirements.txt | 1 + .../debian/06-squeeze/develop/Makefile | 6 +- .../debian/06-squeeze/develop/kaniko-build.py | 196 ------------------ .../06-squeeze/develop/requirements.txt | 1 + .../epicmorg/debian/06-squeeze/jdk11/Makefile | 6 +- .../debian/06-squeeze/jdk11/kaniko-build.py | 196 ------------------ .../debian/06-squeeze/jdk11/requirements.txt | 1 + .../epicmorg/debian/06-squeeze/jdk16/Makefile | 6 +- .../debian/06-squeeze/jdk16/kaniko-build.py | 196 ------------------ .../debian/06-squeeze/jdk16/requirements.txt | 1 + .../epicmorg/debian/06-squeeze/jdk17/Makefile | 6 +- .../debian/06-squeeze/jdk17/kaniko-build.py | 196 ------------------ .../debian/06-squeeze/jdk17/requirements.txt | 1 + .../epicmorg/debian/06-squeeze/jdk18/Makefile | 6 +- .../debian/06-squeeze/jdk18/kaniko-build.py | 196 ------------------ .../debian/06-squeeze/jdk18/requirements.txt | 1 + .../epicmorg/debian/06-squeeze/jdk19/Makefile | 6 +- .../debian/06-squeeze/jdk19/kaniko-build.py | 196 ------------------ .../debian/06-squeeze/jdk19/requirements.txt | 1 + .../epicmorg/debian/06-squeeze/jdk20/Makefile | 6 +- .../debian/06-squeeze/jdk20/kaniko-build.py | 196 ------------------ .../debian/06-squeeze/jdk20/requirements.txt | 1 + .../epicmorg/debian/06-squeeze/jdk21/Makefile | 6 +- .../debian/06-squeeze/jdk21/kaniko-build.py | 196 ------------------ .../debian/06-squeeze/jdk21/requirements.txt | 1 + .../epicmorg/debian/06-squeeze/jdk22/Makefile | 6 +- .../debian/06-squeeze/jdk22/kaniko-build.py | 196 ------------------ .../debian/06-squeeze/jdk22/requirements.txt | 1 + .../epicmorg/debian/06-squeeze/jdk6/Makefile | 6 +- .../debian/06-squeeze/jdk6/kaniko-build.py | 196 ------------------ .../debian/06-squeeze/jdk6/requirements.txt | 1 + .../epicmorg/debian/06-squeeze/jdk7/Makefile | 6 +- .../debian/06-squeeze/jdk7/kaniko-build.py | 196 ------------------ .../debian/06-squeeze/jdk7/requirements.txt | 1 + .../epicmorg/debian/06-squeeze/jdk8/Makefile | 6 +- .../debian/06-squeeze/jdk8/kaniko-build.py | 196 ------------------ .../debian/06-squeeze/jdk8/requirements.txt | 1 + .../epicmorg/debian/06-squeeze/main/Makefile | 6 +- .../debian/06-squeeze/main/kaniko-build.py | 196 ------------------ .../debian/06-squeeze/main/requirements.txt | 1 + .../epicmorg/debian/06-squeeze/slim/Makefile | 6 +- .../debian/06-squeeze/slim/kaniko-build.py | 196 ------------------ .../debian/06-squeeze/slim/requirements.txt | 1 + .../debian/07-wheezy/develop/Makefile | 6 +- .../debian/07-wheezy/develop/kaniko-build.py | 196 ------------------ .../debian/07-wheezy/develop/requirements.txt | 1 + .../epicmorg/debian/07-wheezy/jdk11/Makefile | 6 +- .../debian/07-wheezy/jdk11/kaniko-build.py | 196 ------------------ .../debian/07-wheezy/jdk11/requirements.txt | 1 + .../epicmorg/debian/07-wheezy/jdk16/Makefile | 6 +- .../debian/07-wheezy/jdk16/kaniko-build.py | 196 ------------------ .../debian/07-wheezy/jdk16/requirements.txt | 1 + .../epicmorg/debian/07-wheezy/jdk17/Makefile | 6 +- .../debian/07-wheezy/jdk17/kaniko-build.py | 196 ------------------ .../debian/07-wheezy/jdk17/requirements.txt | 1 + .../epicmorg/debian/07-wheezy/jdk18/Makefile | 6 +- .../debian/07-wheezy/jdk18/kaniko-build.py | 196 ------------------ .../debian/07-wheezy/jdk18/requirements.txt | 1 + .../epicmorg/debian/07-wheezy/jdk19/Makefile | 6 +- .../debian/07-wheezy/jdk19/kaniko-build.py | 196 ------------------ .../debian/07-wheezy/jdk19/requirements.txt | 1 + .../epicmorg/debian/07-wheezy/jdk20/Makefile | 6 +- .../debian/07-wheezy/jdk20/kaniko-build.py | 196 ------------------ .../debian/07-wheezy/jdk20/requirements.txt | 1 + .../epicmorg/debian/07-wheezy/jdk21/Makefile | 6 +- .../debian/07-wheezy/jdk21/kaniko-build.py | 196 ------------------ .../debian/07-wheezy/jdk21/requirements.txt | 1 + .../epicmorg/debian/07-wheezy/jdk22/Makefile | 6 +- .../debian/07-wheezy/jdk22/kaniko-build.py | 196 ------------------ .../debian/07-wheezy/jdk22/requirements.txt | 1 + .../epicmorg/debian/07-wheezy/jdk6/Makefile | 6 +- .../debian/07-wheezy/jdk6/kaniko-build.py | 196 ------------------ .../debian/07-wheezy/jdk6/requirements.txt | 1 + .../epicmorg/debian/07-wheezy/jdk7/Makefile | 6 +- .../debian/07-wheezy/jdk7/kaniko-build.py | 196 ------------------ .../debian/07-wheezy/jdk7/requirements.txt | 1 + .../epicmorg/debian/07-wheezy/jdk8/Makefile | 6 +- .../debian/07-wheezy/jdk8/kaniko-build.py | 196 ------------------ .../debian/07-wheezy/jdk8/requirements.txt | 1 + .../epicmorg/debian/07-wheezy/main/Makefile | 6 +- .../debian/07-wheezy/main/kaniko-build.py | 196 ------------------ .../debian/07-wheezy/main/requirements.txt | 1 + .../epicmorg/debian/07-wheezy/slim/Makefile | 6 +- .../debian/07-wheezy/slim/kaniko-build.py | 196 ------------------ .../debian/07-wheezy/slim/requirements.txt | 1 + .../debian/08-jessie/develop/Makefile | 6 +- .../debian/08-jessie/develop/kaniko-build.py | 196 ------------------ .../debian/08-jessie/develop/requirements.txt | 1 + .../epicmorg/debian/08-jessie/jdk11/Makefile | 6 +- .../debian/08-jessie/jdk11/kaniko-build.py | 196 ------------------ .../debian/08-jessie/jdk11/requirements.txt | 1 + .../epicmorg/debian/08-jessie/jdk16/Makefile | 6 +- .../debian/08-jessie/jdk16/kaniko-build.py | 196 ------------------ .../debian/08-jessie/jdk16/requirements.txt | 1 + .../epicmorg/debian/08-jessie/jdk17/Makefile | 6 +- .../debian/08-jessie/jdk17/kaniko-build.py | 196 ------------------ .../debian/08-jessie/jdk17/requirements.txt | 1 + .../epicmorg/debian/08-jessie/jdk18/Makefile | 6 +- .../debian/08-jessie/jdk18/kaniko-build.py | 196 ------------------ .../debian/08-jessie/jdk18/requirements.txt | 1 + .../epicmorg/debian/08-jessie/jdk19/Makefile | 6 +- .../debian/08-jessie/jdk19/kaniko-build.py | 196 ------------------ .../debian/08-jessie/jdk19/requirements.txt | 1 + .../epicmorg/debian/08-jessie/jdk20/Makefile | 6 +- .../debian/08-jessie/jdk20/kaniko-build.py | 196 ------------------ .../debian/08-jessie/jdk20/requirements.txt | 1 + .../epicmorg/debian/08-jessie/jdk21/Makefile | 6 +- .../debian/08-jessie/jdk21/kaniko-build.py | 196 ------------------ .../debian/08-jessie/jdk21/requirements.txt | 1 + .../epicmorg/debian/08-jessie/jdk22/Makefile | 6 +- .../debian/08-jessie/jdk22/kaniko-build.py | 196 ------------------ .../debian/08-jessie/jdk22/requirements.txt | 1 + .../epicmorg/debian/08-jessie/jdk6/Makefile | 6 +- .../debian/08-jessie/jdk6/kaniko-build.py | 196 ------------------ .../debian/08-jessie/jdk6/requirements.txt | 1 + .../epicmorg/debian/08-jessie/jdk7/Makefile | 6 +- .../debian/08-jessie/jdk7/kaniko-build.py | 196 ------------------ .../debian/08-jessie/jdk7/requirements.txt | 1 + .../epicmorg/debian/08-jessie/jdk8/Makefile | 6 +- .../debian/08-jessie/jdk8/kaniko-build.py | 196 ------------------ .../debian/08-jessie/jdk8/requirements.txt | 1 + .../epicmorg/debian/08-jessie/main/Makefile | 6 +- .../debian/08-jessie/main/kaniko-build.py | 196 ------------------ .../debian/08-jessie/main/requirements.txt | 1 + .../epicmorg/debian/08-jessie/slim/Makefile | 6 +- .../debian/08-jessie/slim/kaniko-build.py | 196 ------------------ .../debian/08-jessie/slim/requirements.txt | 1 + .../debian/09-stretch/develop/Makefile | 6 +- .../debian/09-stretch/develop/kaniko-build.py | 196 ------------------ .../09-stretch/develop/requirements.txt | 1 + .../epicmorg/debian/09-stretch/jdk11/Makefile | 6 +- .../debian/09-stretch/jdk11/kaniko-build.py | 196 ------------------ .../debian/09-stretch/jdk11/requirements.txt | 1 + .../epicmorg/debian/09-stretch/jdk16/Makefile | 6 +- .../debian/09-stretch/jdk16/kaniko-build.py | 196 ------------------ .../debian/09-stretch/jdk16/requirements.txt | 1 + .../epicmorg/debian/09-stretch/jdk17/Makefile | 6 +- .../debian/09-stretch/jdk17/kaniko-build.py | 196 ------------------ .../debian/09-stretch/jdk17/requirements.txt | 1 + .../epicmorg/debian/09-stretch/jdk18/Makefile | 6 +- .../debian/09-stretch/jdk18/kaniko-build.py | 196 ------------------ .../debian/09-stretch/jdk18/requirements.txt | 1 + .../epicmorg/debian/09-stretch/jdk19/Makefile | 6 +- .../debian/09-stretch/jdk19/kaniko-build.py | 196 ------------------ .../debian/09-stretch/jdk19/requirements.txt | 1 + .../epicmorg/debian/09-stretch/jdk20/Makefile | 6 +- .../debian/09-stretch/jdk20/kaniko-build.py | 196 ------------------ .../debian/09-stretch/jdk20/requirements.txt | 1 + .../epicmorg/debian/09-stretch/jdk21/Makefile | 6 +- .../debian/09-stretch/jdk21/kaniko-build.py | 196 ------------------ .../debian/09-stretch/jdk21/requirements.txt | 1 + .../epicmorg/debian/09-stretch/jdk22/Makefile | 6 +- .../debian/09-stretch/jdk22/kaniko-build.py | 196 ------------------ .../debian/09-stretch/jdk22/requirements.txt | 1 + .../epicmorg/debian/09-stretch/jdk6/Makefile | 6 +- .../debian/09-stretch/jdk6/kaniko-build.py | 196 ------------------ .../debian/09-stretch/jdk6/requirements.txt | 1 + .../epicmorg/debian/09-stretch/jdk7/Makefile | 6 +- .../debian/09-stretch/jdk7/kaniko-build.py | 196 ------------------ .../debian/09-stretch/jdk7/requirements.txt | 1 + .../epicmorg/debian/09-stretch/jdk8/Makefile | 6 +- .../debian/09-stretch/jdk8/kaniko-build.py | 196 ------------------ .../debian/09-stretch/jdk8/requirements.txt | 1 + .../epicmorg/debian/09-stretch/main/Makefile | 6 +- .../debian/09-stretch/main/kaniko-build.py | 196 ------------------ .../debian/09-stretch/main/requirements.txt | 1 + .../epicmorg/debian/09-stretch/slim/Makefile | 6 +- .../debian/09-stretch/slim/kaniko-build.py | 196 ------------------ .../debian/09-stretch/slim/requirements.txt | 1 + .../debian/10-buster/develop/Makefile | 6 +- .../debian/10-buster/develop/kaniko-build.py | 196 ------------------ .../debian/10-buster/develop/requirements.txt | 1 + .../epicmorg/debian/10-buster/jdk11/Makefile | 6 +- .../debian/10-buster/jdk11/kaniko-build.py | 196 ------------------ .../debian/10-buster/jdk11/requirements.txt | 1 + .../epicmorg/debian/10-buster/jdk16/Makefile | 6 +- .../debian/10-buster/jdk16/kaniko-build.py | 196 ------------------ .../debian/10-buster/jdk16/requirements.txt | 1 + .../epicmorg/debian/10-buster/jdk17/Makefile | 6 +- .../debian/10-buster/jdk17/kaniko-build.py | 196 ------------------ .../debian/10-buster/jdk17/requirements.txt | 1 + .../epicmorg/debian/10-buster/jdk18/Makefile | 6 +- .../debian/10-buster/jdk18/kaniko-build.py | 196 ------------------ .../debian/10-buster/jdk18/requirements.txt | 1 + .../epicmorg/debian/10-buster/jdk19/Makefile | 6 +- .../debian/10-buster/jdk19/kaniko-build.py | 196 ------------------ .../debian/10-buster/jdk19/requirements.txt | 1 + .../epicmorg/debian/10-buster/jdk20/Makefile | 6 +- .../debian/10-buster/jdk20/kaniko-build.py | 196 ------------------ .../debian/10-buster/jdk20/requirements.txt | 1 + .../epicmorg/debian/10-buster/jdk21/Makefile | 6 +- .../debian/10-buster/jdk21/kaniko-build.py | 196 ------------------ .../debian/10-buster/jdk21/requirements.txt | 1 + .../epicmorg/debian/10-buster/jdk22/Makefile | 6 +- .../debian/10-buster/jdk22/kaniko-build.py | 196 ------------------ .../debian/10-buster/jdk22/requirements.txt | 1 + .../epicmorg/debian/10-buster/jdk6/Makefile | 6 +- .../debian/10-buster/jdk6/kaniko-build.py | 196 ------------------ .../debian/10-buster/jdk6/requirements.txt | 1 + .../epicmorg/debian/10-buster/jdk7/Makefile | 6 +- .../debian/10-buster/jdk7/kaniko-build.py | 196 ------------------ .../debian/10-buster/jdk7/requirements.txt | 1 + .../epicmorg/debian/10-buster/jdk8/Makefile | 6 +- .../debian/10-buster/jdk8/kaniko-build.py | 196 ------------------ .../debian/10-buster/jdk8/requirements.txt | 1 + .../epicmorg/debian/10-buster/main/Makefile | 6 +- .../debian/10-buster/main/kaniko-build.py | 196 ------------------ .../debian/10-buster/main/requirements.txt | 1 + .../epicmorg/debian/10-buster/slim/Makefile | 6 +- .../debian/10-buster/slim/kaniko-build.py | 196 ------------------ .../debian/10-buster/slim/requirements.txt | 1 + .../debian/11-bullseye/develop/Makefile | 6 +- .../11-bullseye/develop/kaniko-build.py | 196 ------------------ .../11-bullseye/develop/requirements.txt | 1 + .../debian/11-bullseye/jdk11/Makefile | 6 +- .../debian/11-bullseye/jdk11/kaniko-build.py | 196 ------------------ .../debian/11-bullseye/jdk11/requirements.txt | 1 + .../debian/11-bullseye/jdk16/Makefile | 6 +- .../debian/11-bullseye/jdk16/kaniko-build.py | 196 ------------------ .../debian/11-bullseye/jdk16/requirements.txt | 1 + .../debian/11-bullseye/jdk17/Makefile | 6 +- .../debian/11-bullseye/jdk17/kaniko-build.py | 196 ------------------ .../debian/11-bullseye/jdk17/requirements.txt | 1 + .../debian/11-bullseye/jdk18/Makefile | 6 +- .../debian/11-bullseye/jdk18/kaniko-build.py | 196 ------------------ .../debian/11-bullseye/jdk18/requirements.txt | 1 + .../debian/11-bullseye/jdk19/Makefile | 6 +- .../debian/11-bullseye/jdk19/kaniko-build.py | 196 ------------------ .../debian/11-bullseye/jdk19/requirements.txt | 1 + .../debian/11-bullseye/jdk20/Makefile | 6 +- .../debian/11-bullseye/jdk20/kaniko-build.py | 196 ------------------ .../debian/11-bullseye/jdk20/requirements.txt | 1 + .../debian/11-bullseye/jdk21/Makefile | 6 +- .../debian/11-bullseye/jdk21/kaniko-build.py | 196 ------------------ .../debian/11-bullseye/jdk21/requirements.txt | 1 + .../debian/11-bullseye/jdk22/Makefile | 6 +- .../debian/11-bullseye/jdk22/kaniko-build.py | 196 ------------------ .../debian/11-bullseye/jdk22/requirements.txt | 1 + .../epicmorg/debian/11-bullseye/jdk6/Makefile | 6 +- .../debian/11-bullseye/jdk6/kaniko-build.py | 196 ------------------ .../debian/11-bullseye/jdk6/requirements.txt | 1 + .../epicmorg/debian/11-bullseye/jdk7/Makefile | 6 +- .../debian/11-bullseye/jdk7/kaniko-build.py | 196 ------------------ .../debian/11-bullseye/jdk7/requirements.txt | 1 + .../epicmorg/debian/11-bullseye/jdk8/Makefile | 6 +- .../debian/11-bullseye/jdk8/kaniko-build.py | 196 ------------------ .../debian/11-bullseye/jdk8/requirements.txt | 1 + .../epicmorg/debian/11-bullseye/main/Makefile | 6 +- .../debian/11-bullseye/main/kaniko-build.py | 196 ------------------ .../debian/11-bullseye/main/requirements.txt | 1 + .../epicmorg/debian/11-bullseye/slim/Makefile | 6 +- .../debian/11-bullseye/slim/kaniko-build.py | 196 ------------------ .../debian/11-bullseye/slim/requirements.txt | 1 + .../debian/12-bookworm/develop/Makefile | 6 +- .../12-bookworm/develop/kaniko-build.py | 196 ------------------ .../12-bookworm/develop/requirements.txt | 1 + .../debian/12-bookworm/jdk11/Makefile | 6 +- .../debian/12-bookworm/jdk11/kaniko-build.py | 196 ------------------ .../debian/12-bookworm/jdk11/requirements.txt | 1 + .../debian/12-bookworm/jdk16/Makefile | 6 +- .../debian/12-bookworm/jdk16/kaniko-build.py | 196 ------------------ .../debian/12-bookworm/jdk16/requirements.txt | 1 + .../debian/12-bookworm/jdk17/Makefile | 6 +- .../debian/12-bookworm/jdk17/kaniko-build.py | 196 ------------------ .../debian/12-bookworm/jdk17/requirements.txt | 1 + .../debian/12-bookworm/jdk18/Makefile | 6 +- .../debian/12-bookworm/jdk18/kaniko-build.py | 196 ------------------ .../debian/12-bookworm/jdk18/requirements.txt | 1 + .../debian/12-bookworm/jdk19/Makefile | 6 +- .../debian/12-bookworm/jdk19/kaniko-build.py | 196 ------------------ .../debian/12-bookworm/jdk19/requirements.txt | 1 + .../debian/12-bookworm/jdk20/Makefile | 6 +- .../debian/12-bookworm/jdk20/kaniko-build.py | 196 ------------------ .../debian/12-bookworm/jdk20/requirements.txt | 1 + .../debian/12-bookworm/jdk21/Makefile | 6 +- .../debian/12-bookworm/jdk21/kaniko-build.py | 196 ------------------ .../debian/12-bookworm/jdk21/requirements.txt | 1 + .../debian/12-bookworm/jdk22/Makefile | 6 +- .../debian/12-bookworm/jdk22/kaniko-build.py | 196 ------------------ .../debian/12-bookworm/jdk22/requirements.txt | 1 + .../epicmorg/debian/12-bookworm/jdk6/Makefile | 6 +- .../debian/12-bookworm/jdk6/kaniko-build.py | 196 ------------------ .../debian/12-bookworm/jdk6/requirements.txt | 1 + .../epicmorg/debian/12-bookworm/jdk7/Makefile | 6 +- .../debian/12-bookworm/jdk7/kaniko-build.py | 196 ------------------ .../debian/12-bookworm/jdk7/requirements.txt | 1 + .../epicmorg/debian/12-bookworm/jdk8/Makefile | 6 +- .../debian/12-bookworm/jdk8/kaniko-build.py | 196 ------------------ .../debian/12-bookworm/jdk8/requirements.txt | 1 + .../epicmorg/debian/12-bookworm/main/Makefile | 6 +- .../debian/12-bookworm/main/kaniko-build.py | 196 ------------------ .../debian/12-bookworm/main/requirements.txt | 1 + .../epicmorg/debian/12-bookworm/slim/Makefile | 6 +- .../debian/12-bookworm/slim/kaniko-build.py | 196 ------------------ .../debian/12-bookworm/slim/requirements.txt | 1 + .../gitlab/runner/amxx-sdk/1.10/Makefile | 6 +- .../runner/amxx-sdk/1.10/kaniko-build.py | 196 ------------------ .../runner/amxx-sdk/1.10/requirements.txt | 1 + .../gitlab/runner/amxx-sdk/1.9/Makefile | 6 +- .../runner/amxx-sdk/1.9/kaniko-build.py | 196 ------------------ .../runner/amxx-sdk/1.9/requirements.txt | 1 + .../gitlab/runner/android-sdk/jdk11/Makefile | 6 +- .../runner/android-sdk/jdk11/kaniko-build.py | 196 ------------------ .../runner/android-sdk/jdk11/requirements.txt | 1 + .../gitlab/runner/android-sdk/jdk17/Makefile | 6 +- .../runner/android-sdk/jdk17/kaniko-build.py | 196 ------------------ .../runner/android-sdk/jdk17/requirements.txt | 1 + .../gitlab/runner/android-sdk/jdk8/Makefile | 6 +- .../runner/android-sdk/jdk8/kaniko-build.py | 196 ------------------ .../runner/android-sdk/jdk8/requirements.txt | 1 + .../gitlab/runner/atlassian-sdk/Makefile | 6 +- .../runner/atlassian-sdk/kaniko-build.py | 196 ------------------ .../runner/atlassian-sdk/requirements.txt | 1 + .../gitlab/runner/dotnet-sdk/Makefile | 6 +- .../gitlab/runner/dotnet-sdk/kaniko-build.py | 196 ------------------ .../gitlab/runner/dotnet-sdk/requirements.txt | 1 + linux/ecosystem/gitlab/runner/latest/Makefile | 6 +- .../gitlab/runner/latest/kaniko-build.py | 196 ------------------ .../gitlab/runner/latest/requirements.txt | 1 + .../ecosystem/gitlab/runner/node0.12/Makefile | 6 +- .../gitlab/runner/node0.12/kaniko-build.py | 196 ------------------ .../gitlab/runner/node0.12/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node10/Makefile | 6 +- .../gitlab/runner/node10/kaniko-build.py | 196 ------------------ .../gitlab/runner/node10/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node11/Makefile | 6 +- .../gitlab/runner/node11/kaniko-build.py | 196 ------------------ .../gitlab/runner/node11/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node12/Makefile | 6 +- .../gitlab/runner/node12/kaniko-build.py | 196 ------------------ .../gitlab/runner/node12/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node13/Makefile | 6 +- .../gitlab/runner/node13/kaniko-build.py | 196 ------------------ .../gitlab/runner/node13/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node14/Makefile | 6 +- .../gitlab/runner/node14/kaniko-build.py | 196 ------------------ .../gitlab/runner/node14/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node15/Makefile | 6 +- .../gitlab/runner/node15/kaniko-build.py | 196 ------------------ .../gitlab/runner/node15/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node16/Makefile | 6 +- .../gitlab/runner/node16/kaniko-build.py | 196 ------------------ .../gitlab/runner/node16/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node17/Makefile | 6 +- .../gitlab/runner/node17/kaniko-build.py | 196 ------------------ .../gitlab/runner/node17/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node18/Makefile | 6 +- .../gitlab/runner/node18/kaniko-build.py | 196 ------------------ .../gitlab/runner/node18/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node19/Makefile | 6 +- .../gitlab/runner/node19/kaniko-build.py | 196 ------------------ .../gitlab/runner/node19/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node20/Makefile | 6 +- .../gitlab/runner/node20/kaniko-build.py | 196 ------------------ .../gitlab/runner/node20/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node21/Makefile | 6 +- .../gitlab/runner/node21/kaniko-build.py | 196 ------------------ .../gitlab/runner/node21/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node22/Makefile | 6 +- .../gitlab/runner/node22/kaniko-build.py | 196 ------------------ .../gitlab/runner/node22/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node4/Makefile | 6 +- .../gitlab/runner/node4/kaniko-build.py | 196 ------------------ .../gitlab/runner/node4/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node5/Makefile | 6 +- .../gitlab/runner/node5/kaniko-build.py | 196 ------------------ .../gitlab/runner/node5/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node6/Makefile | 6 +- .../gitlab/runner/node6/kaniko-build.py | 196 ------------------ .../gitlab/runner/node6/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node7/Makefile | 6 +- .../gitlab/runner/node7/kaniko-build.py | 196 ------------------ .../gitlab/runner/node7/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node8/Makefile | 6 +- .../gitlab/runner/node8/kaniko-build.py | 196 ------------------ .../gitlab/runner/node8/requirements.txt | 1 + linux/ecosystem/gitlab/runner/node9/Makefile | 6 +- .../gitlab/runner/node9/kaniko-build.py | 196 ------------------ .../gitlab/runner/node9/requirements.txt | 1 + linux/ecosystem/gitlab/runner/php7.2/Makefile | 6 +- .../gitlab/runner/php7.2/kaniko-build.py | 196 ------------------ .../gitlab/runner/php7.2/requirements.txt | 1 + linux/ecosystem/gitlab/runner/php7.3/Makefile | 6 +- .../gitlab/runner/php7.3/kaniko-build.py | 196 ------------------ .../gitlab/runner/php7.3/requirements.txt | 1 + linux/ecosystem/gitlab/runner/php7.4/Makefile | 6 +- .../gitlab/runner/php7.4/kaniko-build.py | 196 ------------------ .../gitlab/runner/php7.4/requirements.txt | 1 + linux/ecosystem/gitlab/runner/php8.0/Makefile | 6 +- .../gitlab/runner/php8.0/kaniko-build.py | 196 ------------------ .../gitlab/runner/php8.0/requirements.txt | 1 + linux/ecosystem/gitlab/runner/php8.1/Makefile | 6 +- .../gitlab/runner/php8.1/kaniko-build.py | 196 ------------------ .../gitlab/runner/php8.1/requirements.txt | 1 + linux/ecosystem/gitlab/runner/php8.2/Makefile | 6 +- .../gitlab/runner/php8.2/kaniko-build.py | 196 ------------------ .../gitlab/runner/php8.2/requirements.txt | 1 + linux/ecosystem/gitlab/runner/php8.3/Makefile | 6 +- .../gitlab/runner/php8.3/kaniko-build.py | 196 ------------------ .../gitlab/runner/php8.3/requirements.txt | 1 + .../gitlab/runner/steam-sdk/Makefile | 6 +- .../gitlab/runner/steam-sdk/kaniko-build.py | 196 ------------------ .../gitlab/runner/steam-sdk/requirements.txt | 1 + linux/ecosystem/monero/monerod/Makefile | 6 +- .../ecosystem/monero/monerod/kaniko-build.py | 196 ------------------ .../ecosystem/monero/monerod/requirements.txt | 1 + linux/ecosystem/monero/p2pool/Makefile | 6 +- linux/ecosystem/monero/p2pool/kaniko-build.py | 196 ------------------ .../ecosystem/monero/p2pool/requirements.txt | 1 + linux/ecosystem/nginx/1.14.2/main/Makefile | 6 +- .../nginx/1.14.2/main/kaniko-build.py | 196 ------------------ .../nginx/1.14.2/main/requirements.txt | 1 + linux/ecosystem/nginx/1.14.2/php/Makefile | 6 +- .../nginx/1.14.2/php/kaniko-build.py | 196 ------------------ .../nginx/1.14.2/php/requirements.txt | 1 + .../ecosystem/nginx/1.14.2/rtmp-hls/Makefile | 6 +- .../nginx/1.14.2/rtmp-hls/kaniko-build.py | 196 ------------------ .../nginx/1.14.2/rtmp-hls/requirements.txt | 1 + linux/ecosystem/nginx/1.15.12/main/Makefile | 6 +- .../nginx/1.15.12/main/kaniko-build.py | 196 ------------------ .../nginx/1.15.12/main/requirements.txt | 1 + linux/ecosystem/nginx/1.15.12/php/Makefile | 6 +- .../nginx/1.15.12/php/kaniko-build.py | 196 ------------------ .../nginx/1.15.12/php/requirements.txt | 1 + .../ecosystem/nginx/1.15.12/rtmp-hls/Makefile | 6 +- .../nginx/1.15.12/rtmp-hls/kaniko-build.py | 196 ------------------ .../nginx/1.15.12/rtmp-hls/requirements.txt | 1 + linux/ecosystem/nginx/1.16.1/main/Makefile | 6 +- .../nginx/1.16.1/main/kaniko-build.py | 196 ------------------ .../nginx/1.16.1/main/requirements.txt | 1 + linux/ecosystem/nginx/1.16.1/php/Makefile | 6 +- .../nginx/1.16.1/php/kaniko-build.py | 196 ------------------ .../nginx/1.16.1/php/requirements.txt | 1 + .../ecosystem/nginx/1.16.1/rtmp-hls/Makefile | 6 +- .../nginx/1.16.1/rtmp-hls/kaniko-build.py | 196 ------------------ .../nginx/1.16.1/rtmp-hls/requirements.txt | 1 + linux/ecosystem/nginx/1.17.10/main/Makefile | 6 +- .../nginx/1.17.10/main/kaniko-build.py | 196 ------------------ .../nginx/1.17.10/main/requirements.txt | 1 + linux/ecosystem/nginx/1.17.10/php/Makefile | 6 +- .../nginx/1.17.10/php/kaniko-build.py | 196 ------------------ .../nginx/1.17.10/php/requirements.txt | 1 + .../ecosystem/nginx/1.17.10/rtmp-hls/Makefile | 6 +- .../nginx/1.17.10/rtmp-hls/kaniko-build.py | 196 ------------------ .../nginx/1.17.10/rtmp-hls/requirements.txt | 1 + linux/ecosystem/nginx/1.18.0/main/Makefile | 6 +- .../nginx/1.18.0/main/kaniko-build.py | 196 ------------------ .../nginx/1.18.0/main/requirements.txt | 1 + linux/ecosystem/nginx/1.18.0/php/Makefile | 6 +- .../nginx/1.18.0/php/kaniko-build.py | 196 ------------------ .../nginx/1.18.0/php/requirements.txt | 1 + .../ecosystem/nginx/1.18.0/rtmp-hls/Makefile | 6 +- .../nginx/1.18.0/rtmp-hls/kaniko-build.py | 196 ------------------ .../nginx/1.18.0/rtmp-hls/requirements.txt | 1 + linux/ecosystem/nginx/1.19.10/main/Makefile | 6 +- .../nginx/1.19.10/main/kaniko-build.py | 196 ------------------ .../nginx/1.19.10/main/requirements.txt | 1 + linux/ecosystem/nginx/1.19.10/php/Makefile | 6 +- .../nginx/1.19.10/php/kaniko-build.py | 196 ------------------ .../nginx/1.19.10/php/requirements.txt | 1 + .../ecosystem/nginx/1.19.10/rtmp-hls/Makefile | 6 +- .../nginx/1.19.10/rtmp-hls/kaniko-build.py | 196 ------------------ .../nginx/1.19.10/rtmp-hls/requirements.txt | 1 + linux/ecosystem/nginx/1.20.1/main/Makefile | 6 +- .../nginx/1.20.1/main/kaniko-build.py | 196 ------------------ .../nginx/1.20.1/main/requirements.txt | 1 + linux/ecosystem/nginx/1.20.1/php/Makefile | 6 +- .../nginx/1.20.1/php/kaniko-build.py | 196 ------------------ .../nginx/1.20.1/php/requirements.txt | 1 + .../ecosystem/nginx/1.20.1/rtmp-hls/Makefile | 6 +- .../nginx/1.20.1/rtmp-hls/kaniko-build.py | 196 ------------------ .../nginx/1.20.1/rtmp-hls/requirements.txt | 1 + linux/ecosystem/nginx/1.21.3/main/Makefile | 6 +- .../nginx/1.21.3/main/kaniko-build.py | 196 ------------------ .../nginx/1.21.3/main/requirements.txt | 1 + linux/ecosystem/nginx/1.21.3/php/Makefile | 6 +- .../nginx/1.21.3/php/kaniko-build.py | 196 ------------------ .../nginx/1.21.3/php/requirements.txt | 1 + .../ecosystem/nginx/1.21.3/rtmp-hls/Makefile | 6 +- .../nginx/1.21.3/rtmp-hls/kaniko-build.py | 196 ------------------ .../nginx/1.21.3/rtmp-hls/requirements.txt | 1 + linux/ecosystem/nginx/1.21.6/main/Makefile | 6 +- .../nginx/1.21.6/main/kaniko-build.py | 196 ------------------ .../nginx/1.21.6/main/requirements.txt | 1 + linux/ecosystem/nginx/1.21.6/php/Makefile | 6 +- .../nginx/1.21.6/php/kaniko-build.py | 196 ------------------ .../nginx/1.21.6/php/requirements.txt | 1 + .../ecosystem/nginx/1.21.6/rtmp-hls/Makefile | 6 +- .../nginx/1.21.6/rtmp-hls/kaniko-build.py | 196 ------------------ .../nginx/1.21.6/rtmp-hls/requirements.txt | 1 + linux/ecosystem/nginx/1.27.0/main/Makefile | 6 +- .../nginx/1.27.0/main/etc/nginx/nginx.conf | 9 +- .../nginx/1.27.0/main/kaniko-build.py | 196 ------------------ .../nginx/1.27.0/main/requirements.txt | 1 + .../nginx/latest/mainline/main/Makefile | 4 +- .../latest/mainline/main/kaniko-build.py | 196 ------------------ .../latest/mainline/main/requirements.txt | 1 + .../nginx/latest/mainline/php/Makefile | 6 +- .../nginx/latest/mainline/php/kaniko-build.py | 196 ------------------ .../latest/mainline/php/requirements.txt | 1 + .../nginx/latest/mainline/rtmp-hls/Makefile | 6 +- .../latest/mainline/rtmp-hls/kaniko-build.py | 196 ------------------ .../latest/mainline/rtmp-hls/requirements.txt | 1 + .../ecosystem/nginx/latest/quic/main/Makefile | 6 +- .../nginx/latest/quic/main/kaniko-build.py | 196 ------------------ .../nginx/latest/quic/main/requirements.txt | 1 + .../ecosystem/nginx/latest/quic/php/Makefile | 6 +- .../nginx/latest/quic/php/kaniko-build.py | 196 ------------------ .../nginx/latest/quic/php/requirements.txt | 1 + .../nginx/latest/quic/rtmp-hls/Makefile | 6 +- .../latest/quic/rtmp-hls/kaniko-build.py | 196 ------------------ .../latest/quic/rtmp-hls/requirements.txt | 1 + linux/ecosystem/ninjam/latest/Makefile | 6 +- linux/ecosystem/ninjam/latest/kaniko-build.py | 196 ------------------ .../ecosystem/ninjam/latest/requirements.txt | 1 + linux/ecosystem/nodejs/current/Makefile | 6 +- .../ecosystem/nodejs/current/kaniko-build.py | 196 ------------------ .../ecosystem/nodejs/current/requirements.txt | 1 + linux/ecosystem/nodejs/lts/Makefile | 6 +- linux/ecosystem/nodejs/lts/kaniko-build.py | 196 ------------------ linux/ecosystem/nodejs/lts/requirements.txt | 1 + linux/ecosystem/nodejs/node0.12/Makefile | 6 +- .../ecosystem/nodejs/node0.12/kaniko-build.py | 196 ------------------ .../nodejs/node0.12/requirements.txt | 1 + linux/ecosystem/nodejs/node10/Makefile | 6 +- linux/ecosystem/nodejs/node10/kaniko-build.py | 196 ------------------ .../ecosystem/nodejs/node10/requirements.txt | 1 + linux/ecosystem/nodejs/node11/Makefile | 6 +- linux/ecosystem/nodejs/node11/kaniko-build.py | 196 ------------------ .../ecosystem/nodejs/node11/requirements.txt | 1 + linux/ecosystem/nodejs/node12/Makefile | 6 +- linux/ecosystem/nodejs/node12/kaniko-build.py | 196 ------------------ .../ecosystem/nodejs/node12/requirements.txt | 1 + linux/ecosystem/nodejs/node13/Makefile | 6 +- linux/ecosystem/nodejs/node13/kaniko-build.py | 196 ------------------ .../ecosystem/nodejs/node13/requirements.txt | 1 + linux/ecosystem/nodejs/node14/Makefile | 6 +- linux/ecosystem/nodejs/node14/kaniko-build.py | 196 ------------------ .../ecosystem/nodejs/node14/requirements.txt | 1 + linux/ecosystem/nodejs/node15/Makefile | 6 +- linux/ecosystem/nodejs/node15/kaniko-build.py | 196 ------------------ .../ecosystem/nodejs/node15/requirements.txt | 1 + linux/ecosystem/nodejs/node16/Makefile | 6 +- linux/ecosystem/nodejs/node16/kaniko-build.py | 196 ------------------ .../ecosystem/nodejs/node16/requirements.txt | 1 + linux/ecosystem/nodejs/node17/Makefile | 6 +- linux/ecosystem/nodejs/node17/kaniko-build.py | 196 ------------------ .../ecosystem/nodejs/node17/requirements.txt | 1 + linux/ecosystem/nodejs/node18/Makefile | 6 +- linux/ecosystem/nodejs/node18/kaniko-build.py | 196 ------------------ .../ecosystem/nodejs/node18/requirements.txt | 1 + linux/ecosystem/nodejs/node19/Makefile | 6 +- linux/ecosystem/nodejs/node19/kaniko-build.py | 196 ------------------ .../ecosystem/nodejs/node19/requirements.txt | 1 + linux/ecosystem/nodejs/node20/Makefile | 6 +- linux/ecosystem/nodejs/node20/kaniko-build.py | 196 ------------------ .../ecosystem/nodejs/node20/requirements.txt | 1 + linux/ecosystem/nodejs/node21/Makefile | 6 +- linux/ecosystem/nodejs/node21/kaniko-build.py | 196 ------------------ .../ecosystem/nodejs/node21/requirements.txt | 1 + linux/ecosystem/nodejs/node22/Makefile | 6 +- linux/ecosystem/nodejs/node22/kaniko-build.py | 196 ------------------ .../ecosystem/nodejs/node22/requirements.txt | 1 + linux/ecosystem/nodejs/node4/Makefile | 6 +- linux/ecosystem/nodejs/node4/kaniko-build.py | 196 ------------------ linux/ecosystem/nodejs/node4/requirements.txt | 1 + linux/ecosystem/nodejs/node5/Makefile | 6 +- linux/ecosystem/nodejs/node5/kaniko-build.py | 196 ------------------ linux/ecosystem/nodejs/node5/requirements.txt | 1 + linux/ecosystem/nodejs/node6/Makefile | 6 +- linux/ecosystem/nodejs/node6/kaniko-build.py | 196 ------------------ linux/ecosystem/nodejs/node6/requirements.txt | 1 + linux/ecosystem/nodejs/node7/Makefile | 6 +- linux/ecosystem/nodejs/node7/kaniko-build.py | 196 ------------------ linux/ecosystem/nodejs/node7/requirements.txt | 1 + linux/ecosystem/nodejs/node8/Makefile | 6 +- linux/ecosystem/nodejs/node8/kaniko-build.py | 196 ------------------ linux/ecosystem/nodejs/node8/requirements.txt | 1 + linux/ecosystem/nodejs/node9/Makefile | 6 +- linux/ecosystem/nodejs/node9/kaniko-build.py | 196 ------------------ linux/ecosystem/nodejs/node9/requirements.txt | 1 + linux/ecosystem/opentracker/Makefile | 6 +- linux/ecosystem/opentracker/kaniko-build.py | 196 ------------------ linux/ecosystem/opentracker/requirements.txt | 1 + linux/ecosystem/perforce/base/r16.2/Makefile | 6 +- .../perforce/base/r16.2/kaniko-build.py | 196 ------------------ .../perforce/base/r16.2/requirements.txt | 1 + linux/ecosystem/perforce/base/r17.1/Makefile | 6 +- .../perforce/base/r17.1/kaniko-build.py | 196 ------------------ .../perforce/base/r17.1/requirements.txt | 1 + linux/ecosystem/perforce/base/r17.2/Makefile | 6 +- .../perforce/base/r17.2/kaniko-build.py | 196 ------------------ .../perforce/base/r17.2/requirements.txt | 1 + linux/ecosystem/perforce/base/r18.1/Makefile | 6 +- .../perforce/base/r18.1/kaniko-build.py | 196 ------------------ .../perforce/base/r18.1/requirements.txt | 1 + linux/ecosystem/perforce/base/r18.2/Makefile | 6 +- .../perforce/base/r18.2/kaniko-build.py | 196 ------------------ .../perforce/base/r18.2/requirements.txt | 1 + linux/ecosystem/perforce/base/r19.1/Makefile | 6 +- .../perforce/base/r19.1/kaniko-build.py | 196 ------------------ .../perforce/base/r19.1/requirements.txt | 1 + linux/ecosystem/perforce/base/r19.2/Makefile | 6 +- .../perforce/base/r19.2/kaniko-build.py | 196 ------------------ .../perforce/base/r19.2/requirements.txt | 1 + linux/ecosystem/perforce/base/r20.1/Makefile | 6 +- .../perforce/base/r20.1/kaniko-build.py | 196 ------------------ .../perforce/base/r20.1/requirements.txt | 1 + linux/ecosystem/perforce/base/r20.2/Makefile | 6 +- .../perforce/base/r20.2/kaniko-build.py | 196 ------------------ .../perforce/base/r20.2/requirements.txt | 1 + linux/ecosystem/perforce/base/r21.1/Makefile | 6 +- .../perforce/base/r21.1/kaniko-build.py | 196 ------------------ .../perforce/base/r21.1/requirements.txt | 1 + linux/ecosystem/perforce/base/r21.2/Makefile | 6 +- .../perforce/base/r21.2/kaniko-build.py | 196 ------------------ .../perforce/base/r21.2/requirements.txt | 1 + linux/ecosystem/perforce/base/r22.1/Makefile | 6 +- .../perforce/base/r22.1/kaniko-build.py | 196 ------------------ .../perforce/base/r22.1/requirements.txt | 1 + linux/ecosystem/perforce/base/r23.1/Makefile | 6 +- .../perforce/base/r23.1/kaniko-build.py | 196 ------------------ .../perforce/base/r23.1/requirements.txt | 1 + linux/ecosystem/perforce/base/r23.2/Makefile | 6 +- .../perforce/base/r23.2/kaniko-build.py | 196 ------------------ .../perforce/base/r23.2/requirements.txt | 1 + linux/ecosystem/perforce/p4p/r16.2/Makefile | 6 +- .../perforce/p4p/r16.2/kaniko-build.py | 196 ------------------ .../perforce/p4p/r16.2/requirements.txt | 1 + linux/ecosystem/perforce/p4p/r17.1/Makefile | 6 +- .../perforce/p4p/r17.1/kaniko-build.py | 196 ------------------ .../perforce/p4p/r17.1/requirements.txt | 1 + linux/ecosystem/perforce/p4p/r17.2/Makefile | 6 +- .../perforce/p4p/r17.2/kaniko-build.py | 196 ------------------ .../perforce/p4p/r17.2/requirements.txt | 1 + linux/ecosystem/perforce/p4p/r18.1/Makefile | 6 +- .../perforce/p4p/r18.1/kaniko-build.py | 196 ------------------ .../perforce/p4p/r18.1/requirements.txt | 1 + linux/ecosystem/perforce/p4p/r18.2/Makefile | 6 +- .../perforce/p4p/r18.2/kaniko-build.py | 196 ------------------ .../perforce/p4p/r18.2/requirements.txt | 1 + linux/ecosystem/perforce/p4p/r19.1/Makefile | 6 +- .../perforce/p4p/r19.1/kaniko-build.py | 196 ------------------ .../perforce/p4p/r19.1/requirements.txt | 1 + linux/ecosystem/perforce/p4p/r19.2/Makefile | 6 +- .../perforce/p4p/r19.2/kaniko-build.py | 196 ------------------ .../perforce/p4p/r19.2/requirements.txt | 1 + linux/ecosystem/perforce/p4p/r20.1/Makefile | 6 +- .../perforce/p4p/r20.1/kaniko-build.py | 196 ------------------ .../perforce/p4p/r20.1/requirements.txt | 1 + linux/ecosystem/perforce/p4p/r20.2/Makefile | 6 +- .../perforce/p4p/r20.2/kaniko-build.py | 196 ------------------ .../perforce/p4p/r20.2/requirements.txt | 1 + linux/ecosystem/perforce/p4p/r21.1/Makefile | 6 +- .../perforce/p4p/r21.1/kaniko-build.py | 196 ------------------ .../perforce/p4p/r21.1/requirements.txt | 1 + linux/ecosystem/perforce/p4p/r21.2/Makefile | 6 +- .../perforce/p4p/r21.2/kaniko-build.py | 196 ------------------ .../perforce/p4p/r21.2/requirements.txt | 1 + linux/ecosystem/perforce/p4p/r22.1/Makefile | 6 +- .../perforce/p4p/r22.1/kaniko-build.py | 196 ------------------ .../perforce/p4p/r22.1/requirements.txt | 1 + linux/ecosystem/perforce/p4p/r23.1/Makefile | 6 +- .../perforce/p4p/r23.1/kaniko-build.py | 196 ------------------ .../perforce/p4p/r23.1/requirements.txt | 1 + linux/ecosystem/perforce/p4p/r23.2/Makefile | 6 +- .../perforce/p4p/r23.2/kaniko-build.py | 196 ------------------ .../perforce/p4p/r23.2/requirements.txt | 1 + linux/ecosystem/php/php5.5/Makefile | 6 +- linux/ecosystem/php/php5.5/kaniko-build.py | 196 ------------------ linux/ecosystem/php/php5.5/requirements.txt | 1 + linux/ecosystem/php/php7.0/Makefile | 6 +- linux/ecosystem/php/php7.0/kaniko-build.py | 196 ------------------ linux/ecosystem/php/php7.0/requirements.txt | 1 + linux/ecosystem/php/php7.1/Makefile | 6 +- linux/ecosystem/php/php7.1/kaniko-build.py | 196 ------------------ linux/ecosystem/php/php7.1/requirements.txt | 1 + linux/ecosystem/php/php7.2/Makefile | 6 +- linux/ecosystem/php/php7.2/kaniko-build.py | 196 ------------------ linux/ecosystem/php/php7.2/requirements.txt | 1 + linux/ecosystem/php/php7.3/Makefile | 6 +- linux/ecosystem/php/php7.3/kaniko-build.py | 196 ------------------ linux/ecosystem/php/php7.3/requirements.txt | 1 + linux/ecosystem/php/php7.4/Makefile | 6 +- linux/ecosystem/php/php7.4/kaniko-build.py | 196 ------------------ linux/ecosystem/php/php7.4/requirements.txt | 1 + linux/ecosystem/php/php8.0/Makefile | 6 +- linux/ecosystem/php/php8.0/kaniko-build.py | 196 ------------------ linux/ecosystem/php/php8.0/requirements.txt | 1 + linux/ecosystem/php/php8.1/Makefile | 6 +- linux/ecosystem/php/php8.1/kaniko-build.py | 196 ------------------ linux/ecosystem/php/php8.1/requirements.txt | 1 + linux/ecosystem/php/php8.2/Makefile | 6 +- linux/ecosystem/php/php8.2/kaniko-build.py | 196 ------------------ linux/ecosystem/php/php8.2/requirements.txt | 1 + linux/ecosystem/php/php8.3/Makefile | 6 +- linux/ecosystem/php/php8.3/kaniko-build.py | 196 ------------------ linux/ecosystem/php/php8.3/requirements.txt | 1 + linux/ecosystem/postgres/10/Makefile | 6 +- linux/ecosystem/postgres/10/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/10/requirements.txt | 1 + linux/ecosystem/postgres/11/Makefile | 6 +- linux/ecosystem/postgres/11/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/11/requirements.txt | 1 + linux/ecosystem/postgres/12/Makefile | 6 +- linux/ecosystem/postgres/12/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/12/requirements.txt | 1 + linux/ecosystem/postgres/13/Makefile | 6 +- linux/ecosystem/postgres/13/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/13/requirements.txt | 1 + linux/ecosystem/postgres/14/Makefile | 6 +- linux/ecosystem/postgres/14/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/14/requirements.txt | 1 + linux/ecosystem/postgres/15/Makefile | 6 +- linux/ecosystem/postgres/15/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/15/requirements.txt | 1 + linux/ecosystem/postgres/16/Makefile | 6 +- linux/ecosystem/postgres/16/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/16/requirements.txt | 1 + linux/ecosystem/postgres/8.2/Makefile | 6 +- linux/ecosystem/postgres/8.2/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/8.2/requirements.txt | 1 + linux/ecosystem/postgres/8.3/Makefile | 6 +- linux/ecosystem/postgres/8.3/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/8.3/requirements.txt | 1 + linux/ecosystem/postgres/8.4/Makefile | 6 +- linux/ecosystem/postgres/8.4/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/8.4/requirements.txt | 1 + linux/ecosystem/postgres/9.0/Makefile | 6 +- linux/ecosystem/postgres/9.0/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/9.0/requirements.txt | 1 + linux/ecosystem/postgres/9.1/Makefile | 6 +- linux/ecosystem/postgres/9.1/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/9.1/requirements.txt | 1 + linux/ecosystem/postgres/9.2/Makefile | 6 +- linux/ecosystem/postgres/9.2/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/9.2/requirements.txt | 1 + linux/ecosystem/postgres/9.3/Makefile | 6 +- linux/ecosystem/postgres/9.3/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/9.3/requirements.txt | 1 + linux/ecosystem/postgres/9.4/Makefile | 6 +- linux/ecosystem/postgres/9.4/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/9.4/requirements.txt | 1 + linux/ecosystem/postgres/9.5/Makefile | 6 +- linux/ecosystem/postgres/9.5/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/9.5/requirements.txt | 1 + linux/ecosystem/postgres/9.6/Makefile | 6 +- linux/ecosystem/postgres/9.6/kaniko-build.py | 196 ------------------ linux/ecosystem/postgres/9.6/requirements.txt | 1 + linux/ecosystem/postgres/latest/Makefile | 6 +- .../ecosystem/postgres/latest/kaniko-build.py | 196 ------------------ .../postgres/latest/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.4.0/Makefile | 2 +- .../qbittorrent/4.4.0/kaniko-build.py | 196 ------------------ .../qbittorrent/4.4.0/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.4.1/Makefile | 2 +- .../qbittorrent/4.4.1/kaniko-build.py | 196 ------------------ .../qbittorrent/4.4.1/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.4.2/Makefile | 2 +- .../qbittorrent/4.4.2/kaniko-build.py | 196 ------------------ .../qbittorrent/4.4.2/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.4.3.1/Makefile | 2 +- .../qbittorrent/4.4.3.1/kaniko-build.py | 196 ------------------ .../qbittorrent/4.4.3.1/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.4.4/Makefile | 2 +- .../qbittorrent/4.4.4/kaniko-build.py | 196 ------------------ .../qbittorrent/4.4.4/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.4.5/Makefile | 2 +- .../qbittorrent/4.4.5/kaniko-build.py | 196 ------------------ .../qbittorrent/4.4.5/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.5.0/Makefile | 2 +- .../qbittorrent/4.5.0/kaniko-build.py | 196 ------------------ .../qbittorrent/4.5.0/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.5.1/Makefile | 2 +- .../qbittorrent/4.5.1/kaniko-build.py | 196 ------------------ .../qbittorrent/4.5.1/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.5.2/Makefile | 2 +- .../qbittorrent/4.5.2/kaniko-build.py | 196 ------------------ .../qbittorrent/4.5.2/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.5.3/Makefile | 2 +- .../qbittorrent/4.5.3/kaniko-build.py | 196 ------------------ .../qbittorrent/4.5.3/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.5.4/Makefile | 2 +- .../qbittorrent/4.5.4/kaniko-build.py | 196 ------------------ .../qbittorrent/4.5.4/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.5.5/Makefile | 2 +- .../qbittorrent/4.5.5/kaniko-build.py | 196 ------------------ .../qbittorrent/4.5.5/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.6.0/Makefile | 2 +- .../qbittorrent/4.6.0/kaniko-build.py | 196 ------------------ .../qbittorrent/4.6.0/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.6.1/Makefile | 2 +- .../qbittorrent/4.6.1/kaniko-build.py | 196 ------------------ .../qbittorrent/4.6.1/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.6.2/Makefile | 2 +- .../qbittorrent/4.6.2/kaniko-build.py | 196 ------------------ .../qbittorrent/4.6.2/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.6.3/Makefile | 2 +- .../qbittorrent/4.6.3/kaniko-build.py | 196 ------------------ .../qbittorrent/4.6.3/requirements.txt | 1 + linux/ecosystem/qbittorrent/4.6.4/Makefile | 2 +- .../qbittorrent/4.6.4/kaniko-build.py | 196 ------------------ .../qbittorrent/4.6.4/requirements.txt | 1 + linux/ecosystem/qbittorrent/testing/Makefile | 2 +- .../qbittorrent/testing/kaniko-build.py | 196 ------------------ .../qbittorrent/testing/requirements.txt | 1 + linux/ecosystem/retracker/Makefile | 6 +- linux/ecosystem/retracker/kaniko-build.py | 196 ------------------ linux/ecosystem/retracker/requirements.txt | 1 + .../teamcity/agent/amxx-sdk/1.10/Makefile | 6 +- .../agent/amxx-sdk/1.10/kaniko-build.py | 196 ------------------ .../agent/amxx-sdk/1.10/requirements.txt | 1 + .../teamcity/agent/amxx-sdk/1.9/Makefile | 6 +- .../agent/amxx-sdk/1.9/kaniko-build.py | 196 ------------------ .../agent/amxx-sdk/1.9/requirements.txt | 1 + .../teamcity/agent/android-sdk/jdk11/Makefile | 6 +- .../agent/android-sdk/jdk11/kaniko-build.py | 196 ------------------ .../agent/android-sdk/jdk11/requirements.txt | 1 + .../teamcity/agent/android-sdk/jdk17/Makefile | 6 +- .../agent/android-sdk/jdk17/kaniko-build.py | 196 ------------------ .../agent/android-sdk/jdk17/requirements.txt | 1 + .../teamcity/agent/android-sdk/jdk8/Makefile | 6 +- .../agent/android-sdk/jdk8/kaniko-build.py | 196 ------------------ .../agent/android-sdk/jdk8/requirements.txt | 1 + .../teamcity/agent/atlassian-sdk/Makefile | 6 +- .../agent/atlassian-sdk/kaniko-build.py | 196 ------------------ .../agent/atlassian-sdk/requirements.txt | 1 + .../teamcity/agent/dotnet-sdk/Makefile | 6 +- .../teamcity/agent/dotnet-sdk/kaniko-build.py | 196 ------------------ .../agent/dotnet-sdk/requirements.txt | 1 + .../teamcity/agent/latest/jdk11/Makefile | 6 +- .../agent/latest/jdk11/kaniko-build.py | 196 ------------------ .../agent/latest/jdk11/requirements.txt | 1 + .../teamcity/agent/latest/jdk17/Makefile | 6 +- .../agent/latest/jdk17/kaniko-build.py | 196 ------------------ .../agent/latest/jdk17/requirements.txt | 1 + .../teamcity/agent/latest/jdk21/Makefile | 6 +- .../agent/latest/jdk21/kaniko-build.py | 196 ------------------ .../agent/latest/jdk21/requirements.txt | 1 + .../teamcity/agent/latest/jdk8/Makefile | 6 +- .../agent/latest/jdk8/kaniko-build.py | 196 ------------------ .../agent/latest/jdk8/requirements.txt | 1 + .../teamcity/agent/node0.12/Makefile | 6 +- .../teamcity/agent/node0.12/kaniko-build.py | 196 ------------------ .../teamcity/agent/node0.12/requirements.txt | 1 + .../ecosystem/teamcity/agent/node10/Makefile | 6 +- .../teamcity/agent/node10/kaniko-build.py | 196 ------------------ .../teamcity/agent/node10/requirements.txt | 1 + .../ecosystem/teamcity/agent/node11/Makefile | 6 +- .../teamcity/agent/node11/kaniko-build.py | 196 ------------------ .../teamcity/agent/node11/requirements.txt | 1 + .../ecosystem/teamcity/agent/node12/Makefile | 6 +- .../teamcity/agent/node12/kaniko-build.py | 196 ------------------ .../teamcity/agent/node12/requirements.txt | 1 + .../ecosystem/teamcity/agent/node13/Makefile | 6 +- .../teamcity/agent/node13/kaniko-build.py | 196 ------------------ .../teamcity/agent/node13/requirements.txt | 1 + .../ecosystem/teamcity/agent/node14/Makefile | 6 +- .../teamcity/agent/node14/kaniko-build.py | 196 ------------------ .../teamcity/agent/node14/requirements.txt | 1 + .../ecosystem/teamcity/agent/node15/Makefile | 6 +- .../teamcity/agent/node15/kaniko-build.py | 196 ------------------ .../teamcity/agent/node15/requirements.txt | 1 + .../ecosystem/teamcity/agent/node16/Makefile | 6 +- .../teamcity/agent/node16/kaniko-build.py | 196 ------------------ .../teamcity/agent/node16/requirements.txt | 1 + .../ecosystem/teamcity/agent/node17/Makefile | 6 +- .../teamcity/agent/node17/kaniko-build.py | 196 ------------------ .../teamcity/agent/node17/requirements.txt | 1 + .../ecosystem/teamcity/agent/node18/Makefile | 6 +- .../teamcity/agent/node18/kaniko-build.py | 196 ------------------ .../teamcity/agent/node18/requirements.txt | 1 + .../ecosystem/teamcity/agent/node19/Makefile | 6 +- .../teamcity/agent/node19/kaniko-build.py | 196 ------------------ .../teamcity/agent/node19/requirements.txt | 1 + .../ecosystem/teamcity/agent/node20/Makefile | 6 +- .../teamcity/agent/node20/kaniko-build.py | 196 ------------------ .../teamcity/agent/node20/requirements.txt | 1 + .../ecosystem/teamcity/agent/node21/Makefile | 6 +- .../teamcity/agent/node21/kaniko-build.py | 196 ------------------ .../teamcity/agent/node21/requirements.txt | 1 + .../ecosystem/teamcity/agent/node22/Makefile | 6 +- .../teamcity/agent/node22/kaniko-build.py | 196 ------------------ .../teamcity/agent/node22/requirements.txt | 1 + linux/ecosystem/teamcity/agent/node4/Makefile | 6 +- .../teamcity/agent/node4/kaniko-build.py | 196 ------------------ .../teamcity/agent/node4/requirements.txt | 1 + linux/ecosystem/teamcity/agent/node5/Makefile | 6 +- .../teamcity/agent/node5/kaniko-build.py | 196 ------------------ .../teamcity/agent/node5/requirements.txt | 1 + linux/ecosystem/teamcity/agent/node6/Makefile | 6 +- .../teamcity/agent/node6/kaniko-build.py | 196 ------------------ .../teamcity/agent/node6/requirements.txt | 1 + linux/ecosystem/teamcity/agent/node7/Makefile | 6 +- .../teamcity/agent/node7/kaniko-build.py | 196 ------------------ .../teamcity/agent/node7/requirements.txt | 1 + linux/ecosystem/teamcity/agent/node8/Makefile | 6 +- .../teamcity/agent/node8/kaniko-build.py | 196 ------------------ .../teamcity/agent/node8/requirements.txt | 1 + linux/ecosystem/teamcity/agent/node9/Makefile | 6 +- .../teamcity/agent/node9/kaniko-build.py | 196 ------------------ .../teamcity/agent/node9/requirements.txt | 1 + .../ecosystem/teamcity/agent/php7.2/Makefile | 6 +- .../teamcity/agent/php7.2/kaniko-build.py | 196 ------------------ .../teamcity/agent/php7.2/requirements.txt | 1 + .../ecosystem/teamcity/agent/php7.3/Makefile | 6 +- .../teamcity/agent/php7.3/kaniko-build.py | 196 ------------------ .../teamcity/agent/php7.3/requirements.txt | 1 + .../ecosystem/teamcity/agent/php7.4/Makefile | 6 +- .../teamcity/agent/php7.4/kaniko-build.py | 196 ------------------ .../teamcity/agent/php7.4/requirements.txt | 1 + .../ecosystem/teamcity/agent/php8.0/Makefile | 6 +- .../teamcity/agent/php8.0/kaniko-build.py | 196 ------------------ .../teamcity/agent/php8.0/requirements.txt | 1 + .../ecosystem/teamcity/agent/php8.1/Makefile | 6 +- .../teamcity/agent/php8.1/kaniko-build.py | 196 ------------------ .../teamcity/agent/php8.1/requirements.txt | 1 + .../ecosystem/teamcity/agent/php8.2/Makefile | 6 +- .../teamcity/agent/php8.2/kaniko-build.py | 196 ------------------ .../teamcity/agent/php8.2/requirements.txt | 1 + .../ecosystem/teamcity/agent/php8.3/Makefile | 6 +- .../teamcity/agent/php8.3/kaniko-build.py | 196 ------------------ .../teamcity/agent/php8.3/requirements.txt | 1 + .../teamcity/agent/steam-sdk/Makefile | 6 +- .../teamcity/agent/steam-sdk/kaniko-build.py | 196 ------------------ .../teamcity/agent/steam-sdk/requirements.txt | 1 + .../ecosystem/testrail/5.4.1.3669/ad/Makefile | 6 +- .../testrail/5.4.1.3669/ad/kaniko-build.py | 196 ------------------ .../testrail/5.4.1.3669/ad/requirements.txt | 1 + .../testrail/5.4.1.3669/ldap/Makefile | 6 +- .../testrail/5.4.1.3669/ldap/kaniko-build.py | 196 ------------------ .../testrail/5.4.1.3669/ldap/requirements.txt | 1 + .../testrail/5.4.1.3669/main/Makefile | 6 +- .../testrail/5.4.1.3669/main/kaniko-build.py | 196 ------------------ .../testrail/5.4.1.3669/main/requirements.txt | 1 + .../ecosystem/testrail/5.5.0.3727/ad/Makefile | 6 +- .../testrail/5.5.0.3727/ad/kaniko-build.py | 196 ------------------ .../testrail/5.5.0.3727/ad/requirements.txt | 1 + .../testrail/5.5.0.3727/ldap/Makefile | 6 +- .../testrail/5.5.0.3727/ldap/kaniko-build.py | 196 ------------------ .../testrail/5.5.0.3727/ldap/requirements.txt | 1 + .../testrail/5.5.0.3727/main/Makefile | 6 +- .../testrail/5.5.0.3727/main/kaniko-build.py | 196 ------------------ .../testrail/5.5.0.3727/main/requirements.txt | 1 + .../ecosystem/testrail/5.5.0.3731/ad/Makefile | 6 +- .../testrail/5.5.0.3731/ad/kaniko-build.py | 196 ------------------ .../testrail/5.5.0.3731/ad/requirements.txt | 1 + .../testrail/5.5.0.3731/ldap/Makefile | 6 +- .../testrail/5.5.0.3731/ldap/kaniko-build.py | 196 ------------------ .../testrail/5.5.0.3731/ldap/requirements.txt | 1 + .../testrail/5.5.0.3731/main/Makefile | 6 +- .../testrail/5.5.0.3731/main/kaniko-build.py | 196 ------------------ .../testrail/5.5.0.3731/main/requirements.txt | 1 + .../ecosystem/testrail/5.5.0.3735/ad/Makefile | 6 +- .../testrail/5.5.0.3735/ad/kaniko-build.py | 196 ------------------ .../testrail/5.5.0.3735/ad/requirements.txt | 1 + .../testrail/5.5.0.3735/ldap/Makefile | 6 +- .../testrail/5.5.0.3735/ldap/kaniko-build.py | 196 ------------------ .../testrail/5.5.0.3735/ldap/requirements.txt | 1 + .../testrail/5.5.0.3735/main/Makefile | 6 +- .../testrail/5.5.0.3735/main/kaniko-build.py | 196 ------------------ .../testrail/5.5.0.3735/main/requirements.txt | 1 + .../ecosystem/testrail/5.5.1.3746/ad/Makefile | 6 +- .../testrail/5.5.1.3746/ad/kaniko-build.py | 196 ------------------ .../testrail/5.5.1.3746/ad/requirements.txt | 1 + .../testrail/5.5.1.3746/ldap/Makefile | 6 +- .../testrail/5.5.1.3746/ldap/kaniko-build.py | 196 ------------------ .../testrail/5.5.1.3746/ldap/requirements.txt | 1 + .../testrail/5.5.1.3746/main/Makefile | 6 +- .../testrail/5.5.1.3746/main/kaniko-build.py | 196 ------------------ .../testrail/5.5.1.3746/main/requirements.txt | 1 + .../ecosystem/testrail/5.6.0.3853/ad/Makefile | 6 +- .../testrail/5.6.0.3853/ad/kaniko-build.py | 196 ------------------ .../testrail/5.6.0.3853/ad/requirements.txt | 1 + .../testrail/5.6.0.3853/ldap/Makefile | 6 +- .../testrail/5.6.0.3853/ldap/kaniko-build.py | 196 ------------------ .../testrail/5.6.0.3853/ldap/requirements.txt | 1 + .../testrail/5.6.0.3853/main/Makefile | 6 +- .../testrail/5.6.0.3853/main/kaniko-build.py | 196 ------------------ .../testrail/5.6.0.3853/main/requirements.txt | 1 + .../ecosystem/testrail/5.6.0.3856/ad/Makefile | 6 +- .../testrail/5.6.0.3856/ad/kaniko-build.py | 196 ------------------ .../testrail/5.6.0.3856/ad/requirements.txt | 1 + .../testrail/5.6.0.3856/ldap/Makefile | 6 +- .../testrail/5.6.0.3856/ldap/kaniko-build.py | 196 ------------------ .../testrail/5.6.0.3856/ldap/requirements.txt | 1 + .../testrail/5.6.0.3856/main/Makefile | 6 +- .../testrail/5.6.0.3856/main/kaniko-build.py | 196 ------------------ .../testrail/5.6.0.3856/main/requirements.txt | 1 + .../ecosystem/testrail/5.6.0.3861/ad/Makefile | 6 +- .../testrail/5.6.0.3861/ad/kaniko-build.py | 196 ------------------ .../testrail/5.6.0.3861/ad/requirements.txt | 1 + .../testrail/5.6.0.3861/ldap/Makefile | 6 +- .../testrail/5.6.0.3861/ldap/kaniko-build.py | 196 ------------------ .../testrail/5.6.0.3861/ldap/requirements.txt | 1 + .../testrail/5.6.0.3861/main/Makefile | 6 +- .../testrail/5.6.0.3861/main/kaniko-build.py | 196 ------------------ .../testrail/5.6.0.3861/main/requirements.txt | 1 + .../ecosystem/testrail/5.6.0.3862/ad/Makefile | 6 +- .../testrail/5.6.0.3862/ad/kaniko-build.py | 196 ------------------ .../testrail/5.6.0.3862/ad/requirements.txt | 1 + .../testrail/5.6.0.3862/ldap/Makefile | 6 +- .../testrail/5.6.0.3862/ldap/kaniko-build.py | 196 ------------------ .../testrail/5.6.0.3862/ldap/requirements.txt | 1 + .../testrail/5.6.0.3862/main/Makefile | 6 +- .../testrail/5.6.0.3862/main/kaniko-build.py | 196 ------------------ .../testrail/5.6.0.3862/main/requirements.txt | 1 + .../ecosystem/testrail/5.6.0.3865/ad/Makefile | 6 +- .../testrail/5.6.0.3865/ad/kaniko-build.py | 196 ------------------ .../testrail/5.6.0.3865/ad/requirements.txt | 1 + .../testrail/5.6.0.3865/ldap/Makefile | 6 +- .../testrail/5.6.0.3865/ldap/kaniko-build.py | 196 ------------------ .../testrail/5.6.0.3865/ldap/requirements.txt | 1 + .../testrail/5.6.0.3865/main/Makefile | 6 +- .../testrail/5.6.0.3865/main/kaniko-build.py | 196 ------------------ .../testrail/5.6.0.3865/main/requirements.txt | 1 + .../ecosystem/testrail/5.7.0.3938/ad/Makefile | 6 +- .../testrail/5.7.0.3938/ad/kaniko-build.py | 196 ------------------ .../testrail/5.7.0.3938/ad/requirements.txt | 1 + .../testrail/5.7.0.3938/ldap/Makefile | 6 +- .../testrail/5.7.0.3938/ldap/kaniko-build.py | 196 ------------------ .../testrail/5.7.0.3938/ldap/requirements.txt | 1 + .../testrail/5.7.0.3938/main/Makefile | 6 +- .../testrail/5.7.0.3938/main/kaniko-build.py | 196 ------------------ .../testrail/5.7.0.3938/main/requirements.txt | 1 + .../ecosystem/testrail/5.7.0.3942/ad/Makefile | 6 +- .../testrail/5.7.0.3942/ad/kaniko-build.py | 196 ------------------ .../testrail/5.7.0.3942/ad/requirements.txt | 1 + .../testrail/5.7.0.3942/ldap/Makefile | 6 +- .../testrail/5.7.0.3942/ldap/kaniko-build.py | 196 ------------------ .../testrail/5.7.0.3942/ldap/requirements.txt | 1 + .../testrail/5.7.0.3942/main/Makefile | 6 +- .../testrail/5.7.0.3942/main/kaniko-build.py | 196 ------------------ .../testrail/5.7.0.3942/main/requirements.txt | 1 + .../ecosystem/testrail/5.7.0.3951/ad/Makefile | 6 +- .../testrail/5.7.0.3951/ad/kaniko-build.py | 196 ------------------ .../testrail/5.7.0.3951/ad/requirements.txt | 1 + .../testrail/5.7.0.3951/ldap/Makefile | 6 +- .../testrail/5.7.0.3951/ldap/kaniko-build.py | 196 ------------------ .../testrail/5.7.0.3951/ldap/requirements.txt | 1 + .../testrail/5.7.0.3951/main/Makefile | 6 +- .../testrail/5.7.0.3951/main/kaniko-build.py | 196 ------------------ .../testrail/5.7.0.3951/main/requirements.txt | 1 + .../ecosystem/testrail/5.7.1.4026/ad/Makefile | 6 +- .../testrail/5.7.1.4026/ad/kaniko-build.py | 196 ------------------ .../testrail/5.7.1.4026/ad/requirements.txt | 1 + .../testrail/5.7.1.4026/ldap/Makefile | 6 +- .../testrail/5.7.1.4026/ldap/kaniko-build.py | 196 ------------------ .../testrail/5.7.1.4026/ldap/requirements.txt | 1 + .../testrail/5.7.1.4026/main/Makefile | 6 +- .../testrail/5.7.1.4026/main/kaniko-build.py | 196 ------------------ .../testrail/5.7.1.4026/main/requirements.txt | 1 + .../ecosystem/testrail/5.7.1.4028/ad/Makefile | 6 +- .../testrail/5.7.1.4028/ad/kaniko-build.py | 196 ------------------ .../testrail/5.7.1.4028/ad/requirements.txt | 1 + .../testrail/5.7.1.4028/ldap/Makefile | 6 +- .../testrail/5.7.1.4028/ldap/kaniko-build.py | 196 ------------------ .../testrail/5.7.1.4028/ldap/requirements.txt | 1 + .../testrail/5.7.1.4028/main/Makefile | 6 +- .../testrail/5.7.1.4028/main/kaniko-build.py | 196 ------------------ .../testrail/5.7.1.4028/main/requirements.txt | 1 + .../ecosystem/testrail/6.0.0.4140/ad/Makefile | 6 +- .../testrail/6.0.0.4140/ad/kaniko-build.py | 196 ------------------ .../testrail/6.0.0.4140/ad/requirements.txt | 1 + .../testrail/6.0.0.4140/ldap/Makefile | 6 +- .../testrail/6.0.0.4140/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.0.0.4140/ldap/requirements.txt | 1 + .../testrail/6.0.0.4140/main/Makefile | 6 +- .../testrail/6.0.0.4140/main/kaniko-build.py | 196 ------------------ .../testrail/6.0.0.4140/main/requirements.txt | 1 + .../ecosystem/testrail/6.0.1.4163/ad/Makefile | 6 +- .../testrail/6.0.1.4163/ad/kaniko-build.py | 196 ------------------ .../testrail/6.0.1.4163/ad/requirements.txt | 1 + .../testrail/6.0.1.4163/ldap/Makefile | 6 +- .../testrail/6.0.1.4163/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.0.1.4163/ldap/requirements.txt | 1 + .../testrail/6.0.1.4163/main/Makefile | 6 +- .../testrail/6.0.1.4163/main/kaniko-build.py | 196 ------------------ .../testrail/6.0.1.4163/main/requirements.txt | 1 + .../ecosystem/testrail/6.1.0.4367/ad/Makefile | 6 +- .../testrail/6.1.0.4367/ad/kaniko-build.py | 196 ------------------ .../testrail/6.1.0.4367/ad/requirements.txt | 1 + .../testrail/6.1.0.4367/ldap/Makefile | 6 +- .../testrail/6.1.0.4367/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.1.0.4367/ldap/requirements.txt | 1 + .../testrail/6.1.0.4367/main/Makefile | 6 +- .../testrail/6.1.0.4367/main/kaniko-build.py | 196 ------------------ .../testrail/6.1.0.4367/main/requirements.txt | 1 + .../ecosystem/testrail/6.1.0.4369/ad/Makefile | 6 +- .../testrail/6.1.0.4369/ad/kaniko-build.py | 196 ------------------ .../testrail/6.1.0.4369/ad/requirements.txt | 1 + .../testrail/6.1.0.4369/ldap/Makefile | 6 +- .../testrail/6.1.0.4369/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.1.0.4369/ldap/requirements.txt | 1 + .../testrail/6.1.0.4369/main/Makefile | 6 +- .../testrail/6.1.0.4369/main/kaniko-build.py | 196 ------------------ .../testrail/6.1.0.4369/main/requirements.txt | 1 + .../ecosystem/testrail/6.1.1.1020/ad/Makefile | 6 +- .../testrail/6.1.1.1020/ad/kaniko-build.py | 196 ------------------ .../testrail/6.1.1.1020/ad/requirements.txt | 1 + .../testrail/6.1.1.1020/ldap/Makefile | 6 +- .../testrail/6.1.1.1020/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.1.1.1020/ldap/requirements.txt | 1 + .../testrail/6.1.1.1020/main/Makefile | 6 +- .../testrail/6.1.1.1020/main/kaniko-build.py | 196 ------------------ .../testrail/6.1.1.1020/main/requirements.txt | 1 + .../ecosystem/testrail/6.1.1.1021/ad/Makefile | 6 +- .../testrail/6.1.1.1021/ad/kaniko-build.py | 196 ------------------ .../testrail/6.1.1.1021/ad/requirements.txt | 1 + .../testrail/6.1.1.1021/ldap/Makefile | 6 +- .../testrail/6.1.1.1021/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.1.1.1021/ldap/requirements.txt | 1 + .../testrail/6.1.1.1021/main/Makefile | 6 +- .../testrail/6.1.1.1021/main/kaniko-build.py | 196 ------------------ .../testrail/6.1.1.1021/main/requirements.txt | 1 + .../ecosystem/testrail/6.2.0.1085/ad/Makefile | 6 +- .../testrail/6.2.0.1085/ad/kaniko-build.py | 196 ------------------ .../testrail/6.2.0.1085/ad/requirements.txt | 1 + .../testrail/6.2.0.1085/ldap/Makefile | 6 +- .../testrail/6.2.0.1085/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.2.0.1085/ldap/requirements.txt | 1 + .../testrail/6.2.0.1085/main/Makefile | 6 +- .../testrail/6.2.0.1085/main/kaniko-build.py | 196 ------------------ .../testrail/6.2.0.1085/main/requirements.txt | 1 + .../ecosystem/testrail/6.2.1.1003/ad/Makefile | 6 +- .../testrail/6.2.1.1003/ad/kaniko-build.py | 196 ------------------ .../testrail/6.2.1.1003/ad/requirements.txt | 1 + .../testrail/6.2.1.1003/ldap/Makefile | 6 +- .../testrail/6.2.1.1003/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.2.1.1003/ldap/requirements.txt | 1 + .../testrail/6.2.1.1003/main/Makefile | 6 +- .../testrail/6.2.1.1003/main/kaniko-build.py | 196 ------------------ .../testrail/6.2.1.1003/main/requirements.txt | 1 + .../ecosystem/testrail/6.2.1.1005/ad/Makefile | 6 +- .../testrail/6.2.1.1005/ad/kaniko-build.py | 196 ------------------ .../testrail/6.2.1.1005/ad/requirements.txt | 1 + .../testrail/6.2.1.1005/ldap/Makefile | 6 +- .../testrail/6.2.1.1005/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.2.1.1005/ldap/requirements.txt | 1 + .../testrail/6.2.1.1005/main/Makefile | 6 +- .../testrail/6.2.1.1005/main/kaniko-build.py | 196 ------------------ .../testrail/6.2.1.1005/main/requirements.txt | 1 + .../ecosystem/testrail/6.2.2.1107/ad/Makefile | 6 +- .../testrail/6.2.2.1107/ad/kaniko-build.py | 196 ------------------ .../testrail/6.2.2.1107/ad/requirements.txt | 1 + .../testrail/6.2.2.1107/ldap/Makefile | 6 +- .../testrail/6.2.2.1107/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.2.2.1107/ldap/requirements.txt | 1 + .../testrail/6.2.2.1107/main/Makefile | 6 +- .../testrail/6.2.2.1107/main/kaniko-build.py | 196 ------------------ .../testrail/6.2.2.1107/main/requirements.txt | 1 + .../ecosystem/testrail/6.2.3.1114/ad/Makefile | 6 +- .../testrail/6.2.3.1114/ad/kaniko-build.py | 196 ------------------ .../testrail/6.2.3.1114/ad/requirements.txt | 1 + .../testrail/6.2.3.1114/ldap/Makefile | 6 +- .../testrail/6.2.3.1114/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.2.3.1114/ldap/requirements.txt | 1 + .../testrail/6.2.3.1114/main/Makefile | 6 +- .../testrail/6.2.3.1114/main/kaniko-build.py | 196 ------------------ .../testrail/6.2.3.1114/main/requirements.txt | 1 + .../ecosystem/testrail/6.3.0.1120/ad/Makefile | 6 +- .../testrail/6.3.0.1120/ad/kaniko-build.py | 196 ------------------ .../testrail/6.3.0.1120/ad/requirements.txt | 1 + .../testrail/6.3.0.1120/ldap/Makefile | 6 +- .../testrail/6.3.0.1120/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.3.0.1120/ldap/requirements.txt | 1 + .../testrail/6.3.0.1120/main/Makefile | 6 +- .../testrail/6.3.0.1120/main/kaniko-build.py | 196 ------------------ .../testrail/6.3.0.1120/main/requirements.txt | 1 + .../ecosystem/testrail/6.3.1.1004/ad/Makefile | 6 +- .../testrail/6.3.1.1004/ad/kaniko-build.py | 196 ------------------ .../testrail/6.3.1.1004/ad/requirements.txt | 1 + .../testrail/6.3.1.1004/ldap/Makefile | 6 +- .../testrail/6.3.1.1004/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.3.1.1004/ldap/requirements.txt | 1 + .../testrail/6.3.1.1004/main/Makefile | 6 +- .../testrail/6.3.1.1004/main/kaniko-build.py | 196 ------------------ .../testrail/6.3.1.1004/main/requirements.txt | 1 + .../ecosystem/testrail/6.3.1.1006/ad/Makefile | 6 +- .../testrail/6.3.1.1006/ad/kaniko-build.py | 196 ------------------ .../testrail/6.3.1.1006/ad/requirements.txt | 1 + .../testrail/6.3.1.1006/ldap/Makefile | 6 +- .../testrail/6.3.1.1006/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.3.1.1006/ldap/requirements.txt | 1 + .../testrail/6.3.1.1006/main/Makefile | 6 +- .../testrail/6.3.1.1006/main/kaniko-build.py | 196 ------------------ .../testrail/6.3.1.1006/main/requirements.txt | 1 + .../ecosystem/testrail/6.4.0.1284/ad/Makefile | 6 +- .../testrail/6.4.0.1284/ad/kaniko-build.py | 196 ------------------ .../testrail/6.4.0.1284/ad/requirements.txt | 1 + .../testrail/6.4.0.1284/ldap/Makefile | 6 +- .../testrail/6.4.0.1284/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.4.0.1284/ldap/requirements.txt | 1 + .../testrail/6.4.0.1284/main/Makefile | 6 +- .../testrail/6.4.0.1284/main/kaniko-build.py | 196 ------------------ .../testrail/6.4.0.1284/main/requirements.txt | 1 + .../ecosystem/testrail/6.4.0.1293/ad/Makefile | 6 +- .../testrail/6.4.0.1293/ad/kaniko-build.py | 196 ------------------ .../testrail/6.4.0.1293/ad/requirements.txt | 1 + .../testrail/6.4.0.1293/ldap/Makefile | 6 +- .../testrail/6.4.0.1293/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.4.0.1293/ldap/requirements.txt | 1 + .../testrail/6.4.0.1293/main/Makefile | 6 +- .../testrail/6.4.0.1293/main/kaniko-build.py | 196 ------------------ .../testrail/6.4.0.1293/main/requirements.txt | 1 + .../ecosystem/testrail/6.5.0.1298/ad/Makefile | 6 +- .../testrail/6.5.0.1298/ad/kaniko-build.py | 196 ------------------ .../testrail/6.5.0.1298/ad/requirements.txt | 1 + .../testrail/6.5.0.1298/ldap/Makefile | 6 +- .../testrail/6.5.0.1298/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.5.0.1298/ldap/requirements.txt | 1 + .../testrail/6.5.0.1298/main/Makefile | 6 +- .../testrail/6.5.0.1298/main/kaniko-build.py | 196 ------------------ .../testrail/6.5.0.1298/main/requirements.txt | 1 + .../ecosystem/testrail/6.5.1.1002/ad/Makefile | 6 +- .../testrail/6.5.1.1002/ad/kaniko-build.py | 196 ------------------ .../testrail/6.5.1.1002/ad/requirements.txt | 1 + .../testrail/6.5.1.1002/ldap/Makefile | 6 +- .../testrail/6.5.1.1002/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.5.1.1002/ldap/requirements.txt | 1 + .../testrail/6.5.1.1002/main/Makefile | 6 +- .../testrail/6.5.1.1002/main/kaniko-build.py | 196 ------------------ .../testrail/6.5.1.1002/main/requirements.txt | 1 + .../ecosystem/testrail/6.5.3.1001/ad/Makefile | 6 +- .../testrail/6.5.3.1001/ad/kaniko-build.py | 196 ------------------ .../testrail/6.5.3.1001/ad/requirements.txt | 1 + .../testrail/6.5.3.1001/ldap/Makefile | 6 +- .../testrail/6.5.3.1001/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.5.3.1001/ldap/requirements.txt | 1 + .../testrail/6.5.3.1001/main/Makefile | 6 +- .../testrail/6.5.3.1001/main/kaniko-build.py | 196 ------------------ .../testrail/6.5.3.1001/main/requirements.txt | 1 + .../ecosystem/testrail/6.5.4.1002/ad/Makefile | 6 +- .../testrail/6.5.4.1002/ad/kaniko-build.py | 196 ------------------ .../testrail/6.5.4.1002/ad/requirements.txt | 1 + .../testrail/6.5.4.1002/ldap/Makefile | 6 +- .../testrail/6.5.4.1002/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.5.4.1002/ldap/requirements.txt | 1 + .../testrail/6.5.4.1002/main/Makefile | 6 +- .../testrail/6.5.4.1002/main/kaniko-build.py | 196 ------------------ .../testrail/6.5.4.1002/main/requirements.txt | 1 + .../ecosystem/testrail/6.5.4.1007/ad/Makefile | 6 +- .../testrail/6.5.4.1007/ad/kaniko-build.py | 196 ------------------ .../testrail/6.5.4.1007/ad/requirements.txt | 1 + .../testrail/6.5.4.1007/ldap/Makefile | 6 +- .../testrail/6.5.4.1007/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.5.4.1007/ldap/requirements.txt | 1 + .../testrail/6.5.4.1007/main/Makefile | 6 +- .../testrail/6.5.4.1007/main/kaniko-build.py | 196 ------------------ .../testrail/6.5.4.1007/main/requirements.txt | 1 + .../ecosystem/testrail/6.5.5.1009/ad/Makefile | 6 +- .../testrail/6.5.5.1009/ad/kaniko-build.py | 196 ------------------ .../testrail/6.5.5.1009/ad/requirements.txt | 1 + .../testrail/6.5.5.1009/ldap/Makefile | 6 +- .../testrail/6.5.5.1009/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.5.5.1009/ldap/requirements.txt | 1 + .../testrail/6.5.5.1009/main/Makefile | 6 +- .../testrail/6.5.5.1009/main/kaniko-build.py | 196 ------------------ .../testrail/6.5.5.1009/main/requirements.txt | 1 + .../ecosystem/testrail/6.5.6.1014/ad/Makefile | 6 +- .../testrail/6.5.6.1014/ad/kaniko-build.py | 196 ------------------ .../testrail/6.5.6.1014/ad/requirements.txt | 1 + .../testrail/6.5.6.1014/ldap/Makefile | 6 +- .../testrail/6.5.6.1014/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.5.6.1014/ldap/requirements.txt | 1 + .../testrail/6.5.6.1014/main/Makefile | 6 +- .../testrail/6.5.6.1014/main/kaniko-build.py | 196 ------------------ .../testrail/6.5.6.1014/main/requirements.txt | 1 + .../ecosystem/testrail/6.5.7.1000/ad/Makefile | 6 +- .../testrail/6.5.7.1000/ad/kaniko-build.py | 196 ------------------ .../testrail/6.5.7.1000/ad/requirements.txt | 1 + .../testrail/6.5.7.1000/ldap/Makefile | 6 +- .../testrail/6.5.7.1000/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.5.7.1000/ldap/requirements.txt | 1 + .../testrail/6.5.7.1000/main/Makefile | 6 +- .../testrail/6.5.7.1000/main/kaniko-build.py | 196 ------------------ .../testrail/6.5.7.1000/main/requirements.txt | 1 + .../ecosystem/testrail/6.6.0.1156/ad/Makefile | 6 +- .../testrail/6.6.0.1156/ad/kaniko-build.py | 196 ------------------ .../testrail/6.6.0.1156/ad/requirements.txt | 1 + .../testrail/6.6.0.1156/ldap/Makefile | 6 +- .../testrail/6.6.0.1156/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.6.0.1156/ldap/requirements.txt | 1 + .../testrail/6.6.0.1156/main/Makefile | 6 +- .../testrail/6.6.0.1156/main/kaniko-build.py | 196 ------------------ .../testrail/6.6.0.1156/main/requirements.txt | 1 + .../ecosystem/testrail/6.6.1.1166/ad/Makefile | 6 +- .../testrail/6.6.1.1166/ad/kaniko-build.py | 196 ------------------ .../testrail/6.6.1.1166/ad/requirements.txt | 1 + .../testrail/6.6.1.1166/ldap/Makefile | 6 +- .../testrail/6.6.1.1166/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.6.1.1166/ldap/requirements.txt | 1 + .../testrail/6.6.1.1166/main/Makefile | 6 +- .../testrail/6.6.1.1166/main/kaniko-build.py | 196 ------------------ .../testrail/6.6.1.1166/main/requirements.txt | 1 + .../ecosystem/testrail/6.7.1.1020/ad/Makefile | 6 +- .../testrail/6.7.1.1020/ad/kaniko-build.py | 196 ------------------ .../testrail/6.7.1.1020/ad/requirements.txt | 1 + .../testrail/6.7.1.1020/ldap/Makefile | 6 +- .../testrail/6.7.1.1020/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.7.1.1020/ldap/requirements.txt | 1 + .../testrail/6.7.1.1020/main/Makefile | 6 +- .../testrail/6.7.1.1020/main/kaniko-build.py | 196 ------------------ .../testrail/6.7.1.1020/main/requirements.txt | 1 + .../ecosystem/testrail/6.7.2.1037/ad/Makefile | 6 +- .../testrail/6.7.2.1037/ad/kaniko-build.py | 196 ------------------ .../testrail/6.7.2.1037/ad/requirements.txt | 1 + .../testrail/6.7.2.1037/ldap/Makefile | 6 +- .../testrail/6.7.2.1037/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.7.2.1037/ldap/requirements.txt | 1 + .../testrail/6.7.2.1037/main/Makefile | 6 +- .../testrail/6.7.2.1037/main/kaniko-build.py | 196 ------------------ .../testrail/6.7.2.1037/main/requirements.txt | 1 + .../ecosystem/testrail/6.7.2.1043/ad/Makefile | 6 +- .../testrail/6.7.2.1043/ad/kaniko-build.py | 196 ------------------ .../testrail/6.7.2.1043/ad/requirements.txt | 1 + .../testrail/6.7.2.1043/ldap/Makefile | 6 +- .../testrail/6.7.2.1043/ldap/kaniko-build.py | 196 ------------------ .../testrail/6.7.2.1043/ldap/requirements.txt | 1 + .../testrail/6.7.2.1043/main/Makefile | 6 +- .../testrail/6.7.2.1043/main/kaniko-build.py | 196 ------------------ .../testrail/6.7.2.1043/main/requirements.txt | 1 + .../ecosystem/testrail/7.0.0.1057/ad/Makefile | 6 +- .../testrail/7.0.0.1057/ad/kaniko-build.py | 196 ------------------ .../testrail/7.0.0.1057/ad/requirements.txt | 1 + .../testrail/7.0.0.1057/ldap/Makefile | 6 +- .../testrail/7.0.0.1057/ldap/kaniko-build.py | 196 ------------------ .../testrail/7.0.0.1057/ldap/requirements.txt | 1 + .../testrail/7.0.0.1057/main/Makefile | 6 +- .../testrail/7.0.0.1057/main/kaniko-build.py | 196 ------------------ .../testrail/7.0.0.1057/main/requirements.txt | 1 + .../ecosystem/testrail/7.0.1.1002/ad/Makefile | 6 +- .../testrail/7.0.1.1002/ad/kaniko-build.py | 196 ------------------ .../testrail/7.0.1.1002/ad/requirements.txt | 1 + .../testrail/7.0.1.1002/ldap/Makefile | 6 +- .../testrail/7.0.1.1002/ldap/kaniko-build.py | 196 ------------------ .../testrail/7.0.1.1002/ldap/requirements.txt | 1 + .../testrail/7.0.1.1002/main/Makefile | 6 +- .../testrail/7.0.1.1002/main/kaniko-build.py | 196 ------------------ .../testrail/7.0.1.1002/main/requirements.txt | 1 + .../ecosystem/testrail/7.0.1.1013/ad/Makefile | 6 +- .../testrail/7.0.1.1013/ad/kaniko-build.py | 196 ------------------ .../testrail/7.0.1.1013/ad/requirements.txt | 1 + .../testrail/7.0.1.1013/ldap/Makefile | 6 +- .../testrail/7.0.1.1013/ldap/kaniko-build.py | 196 ------------------ .../testrail/7.0.1.1013/ldap/requirements.txt | 1 + .../testrail/7.0.1.1013/main/Makefile | 6 +- .../testrail/7.0.1.1013/main/kaniko-build.py | 196 ------------------ .../testrail/7.0.1.1013/main/requirements.txt | 1 + .../ecosystem/testrail/7.0.2.1014/ad/Makefile | 6 +- .../testrail/7.0.2.1014/ad/kaniko-build.py | 196 ------------------ .../testrail/7.0.2.1014/ad/requirements.txt | 1 + .../testrail/7.0.2.1014/ldap/Makefile | 6 +- .../testrail/7.0.2.1014/ldap/kaniko-build.py | 196 ------------------ .../testrail/7.0.2.1014/ldap/requirements.txt | 1 + .../testrail/7.0.2.1014/main/Makefile | 6 +- .../testrail/7.0.2.1014/main/kaniko-build.py | 196 ------------------ .../testrail/7.0.2.1014/main/requirements.txt | 1 + .../ecosystem/testrail/7.0.2.1015/ad/Makefile | 6 +- .../testrail/7.0.2.1015/ad/kaniko-build.py | 196 ------------------ .../testrail/7.0.2.1015/ad/requirements.txt | 1 + .../testrail/7.0.2.1015/ldap/Makefile | 6 +- .../testrail/7.0.2.1015/ldap/kaniko-build.py | 196 ------------------ .../testrail/7.0.2.1015/ldap/requirements.txt | 1 + .../testrail/7.0.2.1015/main/Makefile | 6 +- .../testrail/7.0.2.1015/main/kaniko-build.py | 196 ------------------ .../testrail/7.0.2.1015/main/requirements.txt | 1 + .../ecosystem/testrail/7.0.2.1016/ad/Makefile | 6 +- .../testrail/7.0.2.1016/ad/kaniko-build.py | 196 ------------------ .../testrail/7.0.2.1016/ad/requirements.txt | 1 + .../testrail/7.0.2.1016/ldap/Makefile | 6 +- .../testrail/7.0.2.1016/ldap/kaniko-build.py | 196 ------------------ .../testrail/7.0.2.1016/ldap/requirements.txt | 1 + .../testrail/7.0.2.1016/main/Makefile | 6 +- .../testrail/7.0.2.1016/main/kaniko-build.py | 196 ------------------ .../testrail/7.0.2.1016/main/requirements.txt | 1 + .../ecosystem/testrail/7.4.1.8079/ad/Makefile | 6 +- .../testrail/7.4.1.8079/ad/kaniko-build.py | 196 ------------------ .../testrail/7.4.1.8079/ad/requirements.txt | 1 + .../testrail/7.4.1.8079/ldap/Makefile | 6 +- .../testrail/7.4.1.8079/ldap/kaniko-build.py | 196 ------------------ .../testrail/7.4.1.8079/ldap/requirements.txt | 1 + .../testrail/7.4.1.8079/main/Makefile | 6 +- .../testrail/7.4.1.8079/main/kaniko-build.py | 196 ------------------ .../testrail/7.4.1.8079/main/requirements.txt | 1 + .../ecosystem/testrail/7.4.1.8091/ad/Makefile | 6 +- .../testrail/7.4.1.8091/ad/kaniko-build.py | 196 ------------------ .../testrail/7.4.1.8091/ad/requirements.txt | 1 + .../testrail/7.4.1.8091/ldap/Makefile | 6 +- .../testrail/7.4.1.8091/ldap/kaniko-build.py | 196 ------------------ .../testrail/7.4.1.8091/ldap/requirements.txt | 1 + .../testrail/7.4.1.8091/main/Makefile | 6 +- .../testrail/7.4.1.8091/main/kaniko-build.py | 196 ------------------ .../testrail/7.4.1.8091/main/requirements.txt | 1 + .../ecosystem/testrail/7.4.1.8092/ad/Makefile | 6 +- .../testrail/7.4.1.8092/ad/kaniko-build.py | 196 ------------------ .../testrail/7.4.1.8092/ad/requirements.txt | 1 + .../testrail/7.4.1.8092/ldap/Makefile | 6 +- .../testrail/7.4.1.8092/ldap/kaniko-build.py | 196 ------------------ .../testrail/7.4.1.8092/ldap/requirements.txt | 1 + .../testrail/7.4.1.8092/main/Makefile | 6 +- .../testrail/7.4.1.8092/main/kaniko-build.py | 196 ------------------ .../testrail/7.4.1.8092/main/requirements.txt | 1 + .../ecosystem/testrail/7.5.1.7010/ad/Makefile | 6 +- .../testrail/7.5.1.7010/ad/kaniko-build.py | 196 ------------------ .../testrail/7.5.1.7010/ad/requirements.txt | 1 + .../testrail/7.5.1.7010/ldap/Makefile | 6 +- .../testrail/7.5.1.7010/ldap/kaniko-build.py | 196 ------------------ .../testrail/7.5.1.7010/ldap/requirements.txt | 1 + .../testrail/7.5.1.7010/main/Makefile | 6 +- .../testrail/7.5.1.7010/main/kaniko-build.py | 196 ------------------ .../testrail/7.5.1.7010/main/requirements.txt | 1 + .../ecosystem/testrail/7.5.1.7012/ad/Makefile | 6 +- .../testrail/7.5.1.7012/ad/kaniko-build.py | 196 ------------------ .../testrail/7.5.1.7012/ad/requirements.txt | 1 + .../testrail/7.5.1.7012/ldap/Makefile | 6 +- .../testrail/7.5.1.7012/ldap/kaniko-build.py | 196 ------------------ .../testrail/7.5.1.7012/ldap/requirements.txt | 1 + .../testrail/7.5.1.7012/main/Makefile | 6 +- .../testrail/7.5.1.7012/main/kaniko-build.py | 196 ------------------ .../testrail/7.5.1.7012/main/requirements.txt | 1 + .../ecosystem/testrail/7.5.1.7013/ad/Makefile | 6 +- .../testrail/7.5.1.7013/ad/kaniko-build.py | 196 ------------------ .../testrail/7.5.1.7013/ad/requirements.txt | 1 + .../testrail/7.5.1.7013/ldap/Makefile | 6 +- .../testrail/7.5.1.7013/ldap/kaniko-build.py | 196 ------------------ .../testrail/7.5.1.7013/ldap/requirements.txt | 1 + .../testrail/7.5.1.7013/main/Makefile | 6 +- .../testrail/7.5.1.7013/main/kaniko-build.py | 196 ------------------ .../testrail/7.5.1.7013/main/requirements.txt | 1 + .../ecosystem/testrail/7.5.2.1002/ad/Makefile | 6 +- .../testrail/7.5.2.1002/ad/kaniko-build.py | 196 ------------------ .../testrail/7.5.2.1002/ad/requirements.txt | 1 + .../testrail/7.5.2.1002/ldap/Makefile | 6 +- .../testrail/7.5.2.1002/ldap/kaniko-build.py | 196 ------------------ .../testrail/7.5.2.1002/ldap/requirements.txt | 1 + .../testrail/7.5.2.1002/main/Makefile | 6 +- .../testrail/7.5.2.1002/main/kaniko-build.py | 196 ------------------ .../testrail/7.5.2.1002/main/requirements.txt | 1 + .../ecosystem/testrail/7.5.3.1000/ad/Makefile | 6 +- .../testrail/7.5.3.1000/ad/kaniko-build.py | 196 ------------------ .../testrail/7.5.3.1000/ad/requirements.txt | 1 + .../testrail/7.5.3.1000/ldap/Makefile | 6 +- .../testrail/7.5.3.1000/ldap/kaniko-build.py | 196 ------------------ .../testrail/7.5.3.1000/ldap/requirements.txt | 1 + .../testrail/7.5.3.1000/main/Makefile | 6 +- .../testrail/7.5.3.1000/main/kaniko-build.py | 196 ------------------ .../testrail/7.5.3.1000/main/requirements.txt | 1 + .../ecosystem/testrail/8.0.0.1089/ad/Makefile | 6 +- .../testrail/8.0.0.1089/ad/kaniko-build.py | 196 ------------------ .../testrail/8.0.0.1089/ad/requirements.txt | 1 + .../testrail/8.0.0.1089/ldap/Makefile | 6 +- .../testrail/8.0.0.1089/ldap/kaniko-build.py | 196 ------------------ .../testrail/8.0.0.1089/ldap/requirements.txt | 1 + .../testrail/8.0.0.1089/main/Makefile | 6 +- .../testrail/8.0.0.1089/main/kaniko-build.py | 196 ------------------ .../testrail/8.0.0.1089/main/requirements.txt | 1 + .../ecosystem/testrail/8.0.1.1029/ad/Makefile | 6 +- .../testrail/8.0.1.1029/ad/kaniko-build.py | 196 ------------------ .../testrail/8.0.1.1029/ad/requirements.txt | 1 + .../testrail/8.0.1.1029/ldap/Makefile | 6 +- .../testrail/8.0.1.1029/ldap/kaniko-build.py | 196 ------------------ .../testrail/8.0.1.1029/ldap/requirements.txt | 1 + .../testrail/8.0.1.1029/main/Makefile | 6 +- .../testrail/8.0.1.1029/main/kaniko-build.py | 196 ------------------ .../testrail/8.0.1.1029/main/requirements.txt | 1 + linux/ecosystem/torrserver/Makefile | 6 +- linux/ecosystem/torrserver/kaniko-build.py | 196 ------------------ linux/ecosystem/torrserver/requirements.txt | 1 + linux/ecosystem/torrust-index/Makefile | 6 +- linux/ecosystem/torrust-index/kaniko-build.py | 196 ------------------ .../ecosystem/torrust-index/requirements.txt | 1 + linux/ecosystem/torrust-tracker/Makefile | 6 +- .../ecosystem/torrust-tracker/kaniko-build.py | 196 ------------------ .../torrust-tracker/requirements.txt | 1 + linux/ecosystem/vk2discord/Makefile | 6 +- linux/ecosystem/vk2discord/kaniko-build.py | 196 ------------------ linux/ecosystem/vk2discord/requirements.txt | 1 + 4696 files changed, 5662 insertions(+), 334215 deletions(-) delete mode 100644 bin/ansible/roles/atlassian.bitbucket/files/kaniko-build.py delete mode 100644 bin/ansible/roles/atlassian.jira/files/kaniko-build.py delete mode 100644 bin/ansible/roles/gurock.testrail/files/php70/ad/kaniko-build.py delete mode 100644 bin/ansible/roles/gurock.testrail/files/php70/ldap/kaniko-build.py delete mode 100644 bin/ansible/roles/gurock.testrail/files/php70/main/kaniko-build.py delete mode 100644 bin/ansible/roles/gurock.testrail/files/php71/ad/kaniko-build.py delete mode 100644 bin/ansible/roles/gurock.testrail/files/php71/ldap/kaniko-build.py delete mode 100644 bin/ansible/roles/gurock.testrail/files/php71/main/kaniko-build.py delete mode 100644 bin/ansible/roles/gurock.testrail/files/php72/ad/kaniko-build.py delete mode 100644 bin/ansible/roles/gurock.testrail/files/php72/ldap/kaniko-build.py delete mode 100644 bin/ansible/roles/gurock.testrail/files/php72/main/kaniko-build.py delete mode 100644 bin/ansible/roles/gurock.testrail/files/php74/ad/kaniko-build.py delete mode 100644 bin/ansible/roles/gurock.testrail/files/php74/ldap/kaniko-build.py delete mode 100644 bin/ansible/roles/gurock.testrail/files/php74/main/kaniko-build.py delete mode 100644 bin/ansible/roles/gurock.testrail/files/php81/ad/kaniko-build.py delete mode 100644 bin/ansible/roles/gurock.testrail/files/php81/ldap/kaniko-build.py delete mode 100644 bin/ansible/roles/gurock.testrail/files/php81/main/kaniko-build.py delete mode 100644 bin/kaniko/kaniko-build.py delete mode 100644 linux/advanced/mattermost/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/14/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/15/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/16/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/17/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/18/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/19/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/20/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/21/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/22/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/23/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/24/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/25/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/26/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/27/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/28/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/29/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/patched/latest/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/14/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/15/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/16/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/17/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/18/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/19/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/20/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/21/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/22/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/23/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/24/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/25/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/26/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/27/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/28/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/29/kaniko-build.py delete mode 100644 linux/advanced/nextcloud/pure/latest/kaniko-build.py delete mode 100644 linux/advanced/python/develop/2.7/kaniko-build.py delete mode 100644 linux/advanced/python/develop/3.10/kaniko-build.py delete mode 100644 linux/advanced/python/develop/3.11/kaniko-build.py delete mode 100644 linux/advanced/python/develop/3.12/kaniko-build.py delete mode 100644 linux/advanced/python/develop/3.13/kaniko-build.py delete mode 100644 linux/advanced/python/develop/3.6/kaniko-build.py delete mode 100644 linux/advanced/python/develop/3.7/kaniko-build.py delete mode 100644 linux/advanced/python/develop/3.8/kaniko-build.py delete mode 100644 linux/advanced/python/develop/3.9/kaniko-build.py delete mode 100644 linux/advanced/python/main/2.7/kaniko-build.py delete mode 100644 linux/advanced/python/main/3.10/kaniko-build.py delete mode 100644 linux/advanced/python/main/3.11/kaniko-build.py delete mode 100644 linux/advanced/python/main/3.12/kaniko-build.py delete mode 100644 linux/advanced/python/main/3.13/kaniko-build.py delete mode 100644 linux/advanced/python/main/3.6/kaniko-build.py delete mode 100644 linux/advanced/python/main/3.7/kaniko-build.py delete mode 100644 linux/advanced/python/main/3.8/kaniko-build.py delete mode 100644 linux/advanced/python/main/3.9/kaniko-build.py delete mode 100644 linux/advanced/sentry/latest/kaniko-build.py delete mode 100644 linux/advanced/teamcity/server/kaniko-build.py delete mode 100644 linux/advanced/vscode-server/amxx/1.10/kaniko-build.py delete mode 100644 linux/advanced/vscode-server/amxx/1.9/kaniko-build.py delete mode 100644 linux/advanced/vscode-server/android/kaniko-build.py delete mode 100644 linux/advanced/vscode-server/cpp/kaniko-build.py delete mode 100644 linux/advanced/vscode-server/devops/kaniko-build.py delete mode 100644 linux/advanced/vscode-server/docker/kaniko-build.py delete mode 100644 linux/advanced/vscode-server/dotnet-full/kaniko-build.py delete mode 100644 linux/advanced/vscode-server/dotnet/kaniko-build.py delete mode 100644 linux/advanced/vscode-server/latest/kaniko-build.py delete mode 100644 linux/advanced/vscode-server/mono/kaniko-build.py delete mode 100644 linux/advanced/zabbix/3.0/agent/kaniko-build.py delete mode 100644 linux/advanced/zabbix/3.0/java-gateway/kaniko-build.py delete mode 100644 linux/advanced/zabbix/3.0/proxy-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/3.0/proxy-sqlite3/kaniko-build.py delete mode 100644 linux/advanced/zabbix/3.0/server-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/3.0/server-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/3.0/snmptraps/kaniko-build.py delete mode 100644 linux/advanced/zabbix/3.0/web-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/3.0/web-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/4.0/agent/kaniko-build.py delete mode 100644 linux/advanced/zabbix/4.0/java-gateway/kaniko-build.py delete mode 100644 linux/advanced/zabbix/4.0/proxy-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/4.0/proxy-sqlite3/kaniko-build.py delete mode 100644 linux/advanced/zabbix/4.0/server-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/4.0/server-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/4.0/snmptraps/kaniko-build.py delete mode 100644 linux/advanced/zabbix/4.0/web-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/4.0/web-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.0/agent/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.0/agent2/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.0/java-gateway/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.0/proxy-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.0/proxy-sqlite3/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.0/server-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.0/server-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.0/snmptraps/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.0/web-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.0/web-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.2/agent/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.2/agent2/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.2/java-gateway/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.2/proxy-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.2/proxy-sqlite3/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.2/server-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.2/server-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.2/snmptraps/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.2/web-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.2/web-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.4/agent/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.4/agent2/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.4/java-gateway/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.4/proxy-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.4/proxy-sqlite3/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.4/server-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.4/server-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.4/snmptraps/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.4/web-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/5.4/web-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.0/agent/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.0/agent2/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.0/java-gateway/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.0/proxy-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.0/proxy-sqlite3/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.0/server-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.0/server-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.0/snmptraps/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.0/web-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.0/web-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.2/agent/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.2/agent2/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.2/java-gateway/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.2/proxy-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.2/proxy-sqlite3/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.2/server-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.2/server-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.2/snmptraps/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.2/web-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.2/web-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.4/agent/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.4/agent2/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.4/java-gateway/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.4/proxy-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.4/proxy-sqlite3/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.4/server-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.4/server-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.4/snmptraps/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.4/web-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/6.4/web-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/latest/agent/kaniko-build.py delete mode 100644 linux/advanced/zabbix/latest/agent2/kaniko-build.py delete mode 100644 linux/advanced/zabbix/latest/java-gateway/kaniko-build.py delete mode 100644 linux/advanced/zabbix/latest/proxy-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/latest/proxy-sqlite3/kaniko-build.py delete mode 100644 linux/advanced/zabbix/latest/server-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/latest/server-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/latest/snmptraps/kaniko-build.py delete mode 100644 linux/advanced/zabbix/latest/web-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/latest/web-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/trunk/agent/kaniko-build.py delete mode 100644 linux/advanced/zabbix/trunk/agent2/kaniko-build.py delete mode 100644 linux/advanced/zabbix/trunk/java-gateway/kaniko-build.py delete mode 100644 linux/advanced/zabbix/trunk/proxy-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/trunk/proxy-sqlite3/kaniko-build.py delete mode 100644 linux/advanced/zabbix/trunk/server-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/trunk/server-pgsql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/trunk/snmptraps/kaniko-build.py delete mode 100644 linux/advanced/zabbix/trunk/web-mysql/kaniko-build.py delete mode 100644 linux/advanced/zabbix/trunk/web-pgsql/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/devel/jdk11/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/devel/jdk16/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/devel/jdk6/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/devel/jdk7/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/devel/jdk8/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/devel/main/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/edge/jdk11/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/edge/jdk16/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/edge/jdk6/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/edge/jdk7/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/edge/jdk8/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/edge/main/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/prod/jdk11/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/prod/jdk16/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/prod/jdk6/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/prod/jdk7/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/prod/jdk8/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/epicmorg/prod/main/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.0/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.1/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.2/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.3.1/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.3.2/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.3/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/freegpt-webui/1.4/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/freegpt-webui/latest/kaniko-build.py delete mode 100644 linux/discontinued/ecosystem/syspass/sysPass/kaniko-build.py delete mode 100644 linux/ecosystem/apache2/php5.5/kaniko-build.py delete mode 100644 linux/ecosystem/apache2/php7.0/kaniko-build.py delete mode 100644 linux/ecosystem/apache2/php7.1/kaniko-build.py delete mode 100644 linux/ecosystem/apache2/php7.2/kaniko-build.py delete mode 100644 linux/ecosystem/apache2/php7.3/kaniko-build.py delete mode 100644 linux/ecosystem/apache2/php7.4/kaniko-build.py delete mode 100644 linux/ecosystem/apache2/php8.0/kaniko-build.py delete mode 100644 linux/ecosystem/apache2/php8.1/kaniko-build.py delete mode 100644 linux/ecosystem/apache2/php8.2/kaniko-build.py delete mode 100644 linux/ecosystem/apache2/php8.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/1/1.0.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/1/1.1.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/1/1.2.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/1/1.2.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/1/1.3.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.0.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.1.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.10.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.11.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.12.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.2.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.3.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.4.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.5.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.6.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.7.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.8.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.8.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.9.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.9.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.9.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.9.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/2/2.9.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.0.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.1.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.10.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.10.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.10.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.10.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.11.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.2.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.2.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.2.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.2.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.2.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.3.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.3.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.3.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.3.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.3.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.4.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.4.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.4.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.4.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.5.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.5.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.6.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.6.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.7.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.7.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.7.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.7.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.7.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.8.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.8.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.9.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/3/3.9.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.0.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.1.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.1.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.1.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.1.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.10.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.10.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.10.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.11.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.11.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.12.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.12.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.13.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.13.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.11/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.12/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.14.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.2.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.2.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.2.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.2.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.3.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.3.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.3.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.3.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.4.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.4.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.4.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.4.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.5.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.5.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.5.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.6.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.6.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.6.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.6.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.6.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.7.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.7.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.8.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.9.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/4/4.9.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/7/7.21.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.0.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.0.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.1.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.1.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.12.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.17.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.19.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.2.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.2.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.3.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.3.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.3.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.3.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.4.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.4.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.4.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.5.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.5.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.6.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.6.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/8/8.7.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/9/9.0.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/bitbucket/latest/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.0.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.1.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.1.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.1.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.1.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.1.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.10.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.10.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.10.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.10.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.11.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.11.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.11.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.12.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.12.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.12.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.12.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.12.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.11/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.12/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.13/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.15/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.17/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.18/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.19/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.20/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.21/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.13.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.14.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.14.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.14.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.14.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.15.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.2.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.2.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.2.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.2.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.2.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.3.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.3.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.3.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.3.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.4.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.4.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.4.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.4.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.5.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.5.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.5.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.5.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.11/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.12/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.13/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.14/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.15/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.16/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.17/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.6.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.7.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.7.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.7.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.7.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.8.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.8.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.8.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.8.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.8.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.9.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.9.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/6/6.9.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.16/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.17/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.18/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/7/7.19.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/7/7.20.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/7/7.20.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/7/7.20.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/7/7.20.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/8/8.0.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/8/8.0.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/8/8.0.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/8/8.4.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/8/8.5.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/8/8.6.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/8/8.7.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/8/8.8.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/8/8.9.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/9/9.0.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/latest/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/templates/5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/confluence/templates/6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crowd/5/5.1.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crowd/latest/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.0.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.0.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.1.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.1.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.1.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.1.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.2.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.2.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.2.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.5.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.5.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.5.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.5.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.0Beta1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.0Beta2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.2.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.5.a/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.5a/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/1/1.6.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/crucible/templates/1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.B3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.0.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.M2cc/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.RC1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.1.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.10.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.2.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.2.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.2.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.3.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.4.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.5.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.6.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.11/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.12/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.13/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.14/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.15/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.7.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0-m1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.8.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.8.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.9.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.9.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/2/2.9.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.0.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.0.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.0.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.0.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.0.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.1.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.10.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.10.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.10.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.10.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.2.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.3.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.3.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.3.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.3.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.3.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.4.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.5.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.6.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.6.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.6.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.6.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.6.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.7.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.7.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.8.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.8.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.9.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.9.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/3/3.9.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.0.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.0.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.0.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.1.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.1.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.1.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.1.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.2.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.2.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.2.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.2.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.3.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.3.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.3.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.3.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.4.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.5.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.5.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.5.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.5.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.5.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.6.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.6.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.7.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.7.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.7.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.7.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/4/4.8.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/latest/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/templates/2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/templates/3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye-crucible/templates/4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.0.1a/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.1.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.2.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.3.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.4.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.4.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.4.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.5.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.5.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.5.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.5.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.0Beta1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.0Beta2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.5.a/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.5a/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/1/1.6.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/fisheye/templates/1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.1.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.1.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.2.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.2.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.2.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.2.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.3.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.3.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.3.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.3.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.4.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.4.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.4.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.4.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/4/4.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.0.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.0.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.0.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.0.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.0.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.0.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.0.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.1.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.1.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.1.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.1.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.1.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.1.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.1.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.1.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.2.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.2.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.2.11/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.2.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.2.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.2.4.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.2.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.2.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.2.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.2.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.2.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.2.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/5/5.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.0.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.0.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.0.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.0.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.0.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.0.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.0.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.0.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.1.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.1.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.1.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.1.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.1.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.1.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.1.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.1.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.1.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.2.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.2.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.2.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.2.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.2.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.2.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.2.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.3.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.3.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.3.11/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.3.12/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.3.13/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.3.14/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.3.15/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.3.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.3.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.3.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.3.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.3.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.3.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.3.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.4.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.4.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.4.11/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.4.12/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.4.13/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.4.14/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.4.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.4.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.4.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.4.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.4.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.4.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.4.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.4.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/6/6.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.0.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.0.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.0.11/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.0.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.0.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.0.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.0.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.1.0-m01/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.1.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.1.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.1.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.1.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.1.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.1.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.1.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.1.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.1.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.10.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.10.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.10.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.11.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.11.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.11.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.12.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.12.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.12.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.11/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.12/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.13/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.14/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.15/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.16/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.17/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.18/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.13.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.2.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.2.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.2.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.2.11/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.2.12/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.2.13/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.2.14/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.2.15/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.2.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.2.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.2.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.2.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.2.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.2.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.2.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.3.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.3.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.3.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.3.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.3.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.3.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.3.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.3.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.3.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.3.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.4.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.4.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.4.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.4.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.4.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.4.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.4.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.5.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.5.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.5.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.5.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.5.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.11/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.12/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.13/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.14/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.15/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.16/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.17/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.6.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.7.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.7.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.7.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.7.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.8.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.8.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.8.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.8.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.9.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/7/7.9.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.0.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.0.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.0.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.1.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.1.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.1.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.1.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.10.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.10.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.11.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.11.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.12.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.12.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.12.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.12.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.11/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.12/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.13/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.14/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.15/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.16/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.17/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.18/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.19/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.20/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.21/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.22/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.24/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.25/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.26/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.27/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.13.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.14.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.14.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.15.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.15.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.16.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.16.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.16.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.17.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.17.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.18.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.18.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.19.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.19.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.2.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.2.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.2.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.2.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.2.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.2.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.2.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.11/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.12/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.13/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.14/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.15/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.16/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.17/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.19/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.20/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.21/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.22/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.23/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.24/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.25/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.26/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.27/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.28/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.29/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.30/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.20.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.21.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.21.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.22.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.22.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.22.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.22.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.22.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.22.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.22.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.3.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.3.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.3.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.3.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.3.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.3.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.4.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.4.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.4.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.4.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.11/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.12/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.13/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.14/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.15/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.16/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.17/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.18/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.19/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.5.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.6.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.6.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.7.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.7.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.8.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.8.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.9.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/8/8.9.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.0.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.1.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.1.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.10.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.10.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.10.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.11.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.11.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.11.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.11.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.12.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.12.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.12.12/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.12.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.14.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.16.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.17.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.2.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.2.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.3.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.3.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.3.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.3.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.4.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.4.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.4.10/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.4.11/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.4.12/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.4.14/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.4.15/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.4.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.4.3/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.4.4/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.4.5/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.4.6/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.4.7/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.4.8/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.4.9/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.5.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.5.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.6.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.7.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.7.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.7.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.8.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.8.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.8.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.9.0/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.9.1/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/9/9.9.2/kaniko-build.py delete mode 100644 linux/ecosystem/atlassian/jira/latest/kaniko-build.py delete mode 100644 linux/ecosystem/cassandra/3.11/kaniko-build.py delete mode 100644 linux/ecosystem/electron-release-server/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/develop/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/main/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/astra/1.7-alse/slim/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/develop/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/main/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/06-squeeze/slim/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/develop/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/main/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/07-wheezy/slim/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/develop/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk11/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk16/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk17/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk18/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk19/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk20/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk21/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk22/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk6/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk7/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/jdk8/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/main/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/08-jessie/slim/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/develop/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk11/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk16/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk17/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk18/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk19/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk20/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk21/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk22/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk6/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk7/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/jdk8/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/main/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/09-stretch/slim/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/10-buster/develop/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk11/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk16/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk17/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk18/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk19/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk20/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk21/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk22/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk6/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk7/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/10-buster/jdk8/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/10-buster/main/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/10-buster/slim/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/develop/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/main/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/11-bullseye/slim/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/develop/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/main/kaniko-build.py delete mode 100644 linux/ecosystem/epicmorg/debian/12-bookworm/slim/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/amxx-sdk/1.10/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/amxx-sdk/1.9/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/android-sdk/jdk11/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/android-sdk/jdk17/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/android-sdk/jdk8/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/atlassian-sdk/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/dotnet-sdk/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/latest/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node0.12/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node10/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node11/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node12/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node13/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node14/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node15/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node16/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node17/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node18/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node19/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node20/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node21/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node22/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node4/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node5/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node6/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node7/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node8/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/node9/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/php7.2/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/php7.3/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/php7.4/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/php8.0/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/php8.1/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/php8.2/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/php8.3/kaniko-build.py delete mode 100644 linux/ecosystem/gitlab/runner/steam-sdk/kaniko-build.py delete mode 100644 linux/ecosystem/monero/monerod/kaniko-build.py delete mode 100644 linux/ecosystem/monero/p2pool/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.14.2/main/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.14.2/php/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.14.2/rtmp-hls/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.15.12/main/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.15.12/php/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.15.12/rtmp-hls/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.16.1/main/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.16.1/php/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.16.1/rtmp-hls/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.17.10/main/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.17.10/php/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.17.10/rtmp-hls/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.18.0/main/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.18.0/php/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.18.0/rtmp-hls/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.19.10/main/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.19.10/php/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.19.10/rtmp-hls/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.20.1/main/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.20.1/php/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.20.1/rtmp-hls/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.21.3/main/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.21.3/php/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.21.3/rtmp-hls/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.21.6/main/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.21.6/php/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.21.6/rtmp-hls/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/1.27.0/main/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/latest/mainline/main/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/latest/mainline/php/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/latest/mainline/rtmp-hls/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/latest/quic/main/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/latest/quic/php/kaniko-build.py delete mode 100644 linux/ecosystem/nginx/latest/quic/rtmp-hls/kaniko-build.py delete mode 100644 linux/ecosystem/ninjam/latest/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/current/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/lts/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node0.12/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node10/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node11/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node12/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node13/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node14/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node15/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node16/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node17/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node18/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node19/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node20/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node21/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node22/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node4/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node5/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node6/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node7/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node8/kaniko-build.py delete mode 100644 linux/ecosystem/nodejs/node9/kaniko-build.py delete mode 100644 linux/ecosystem/opentracker/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/base/r16.2/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/base/r17.1/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/base/r17.2/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/base/r18.1/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/base/r18.2/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/base/r19.1/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/base/r19.2/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/base/r20.1/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/base/r20.2/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/base/r21.1/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/base/r21.2/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/base/r22.1/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/base/r23.1/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/base/r23.2/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/p4p/r16.2/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/p4p/r17.1/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/p4p/r17.2/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/p4p/r18.1/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/p4p/r18.2/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/p4p/r19.1/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/p4p/r19.2/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/p4p/r20.1/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/p4p/r20.2/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/p4p/r21.1/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/p4p/r21.2/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/p4p/r22.1/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/p4p/r23.1/kaniko-build.py delete mode 100644 linux/ecosystem/perforce/p4p/r23.2/kaniko-build.py delete mode 100644 linux/ecosystem/php/php5.5/kaniko-build.py delete mode 100644 linux/ecosystem/php/php7.0/kaniko-build.py delete mode 100644 linux/ecosystem/php/php7.1/kaniko-build.py delete mode 100644 linux/ecosystem/php/php7.2/kaniko-build.py delete mode 100644 linux/ecosystem/php/php7.3/kaniko-build.py delete mode 100644 linux/ecosystem/php/php7.4/kaniko-build.py delete mode 100644 linux/ecosystem/php/php8.0/kaniko-build.py delete mode 100644 linux/ecosystem/php/php8.1/kaniko-build.py delete mode 100644 linux/ecosystem/php/php8.2/kaniko-build.py delete mode 100644 linux/ecosystem/php/php8.3/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/10/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/11/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/12/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/13/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/14/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/15/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/16/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/8.2/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/8.3/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/8.4/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/9.0/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/9.1/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/9.2/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/9.3/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/9.4/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/9.5/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/9.6/kaniko-build.py delete mode 100644 linux/ecosystem/postgres/latest/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.4.0/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.4.1/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.4.2/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.4.3.1/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.4.4/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.4.5/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.5.0/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.5.1/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.5.2/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.5.3/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.5.4/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.5.5/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.6.0/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.6.1/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.6.2/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.6.3/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/4.6.4/kaniko-build.py delete mode 100644 linux/ecosystem/qbittorrent/testing/kaniko-build.py delete mode 100644 linux/ecosystem/retracker/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/amxx-sdk/1.10/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/amxx-sdk/1.9/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/android-sdk/jdk11/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/android-sdk/jdk17/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/android-sdk/jdk8/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/atlassian-sdk/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/dotnet-sdk/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/latest/jdk11/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/latest/jdk17/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/latest/jdk21/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/latest/jdk8/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node0.12/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node10/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node11/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node12/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node13/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node14/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node15/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node16/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node17/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node18/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node19/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node20/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node21/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node22/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node4/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node5/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node6/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node7/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node8/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/node9/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/php7.2/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/php7.3/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/php7.4/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/php8.0/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/php8.1/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/php8.2/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/php8.3/kaniko-build.py delete mode 100644 linux/ecosystem/teamcity/agent/steam-sdk/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.4.1.3669/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.4.1.3669/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.4.1.3669/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.5.0.3727/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.5.0.3727/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.5.0.3727/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.5.0.3731/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.5.0.3731/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.5.0.3731/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.5.0.3735/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.5.0.3735/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.5.0.3735/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.5.1.3746/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.5.1.3746/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.5.1.3746/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.6.0.3853/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.6.0.3853/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.6.0.3853/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.6.0.3856/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.6.0.3856/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.6.0.3856/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.6.0.3861/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.6.0.3861/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.6.0.3861/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.6.0.3862/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.6.0.3862/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.6.0.3862/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.6.0.3865/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.6.0.3865/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.6.0.3865/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.7.0.3938/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.7.0.3938/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.7.0.3938/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.7.0.3942/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.7.0.3942/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.7.0.3942/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.7.0.3951/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.7.0.3951/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.7.0.3951/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.7.1.4026/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.7.1.4026/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.7.1.4026/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.7.1.4028/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.7.1.4028/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/5.7.1.4028/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.0.0.4140/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.0.0.4140/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.0.0.4140/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.0.1.4163/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.0.1.4163/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.0.1.4163/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.1.0.4367/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.1.0.4367/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.1.0.4367/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.1.0.4369/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.1.0.4369/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.1.0.4369/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.1.1.1020/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.1.1.1020/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.1.1.1020/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.1.1.1021/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.1.1.1021/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.1.1.1021/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.2.0.1085/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.2.0.1085/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.2.0.1085/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.2.1.1003/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.2.1.1003/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.2.1.1003/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.2.1.1005/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.2.1.1005/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.2.1.1005/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.2.2.1107/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.2.2.1107/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.2.2.1107/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.2.3.1114/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.2.3.1114/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.2.3.1114/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.3.0.1120/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.3.0.1120/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.3.0.1120/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.3.1.1004/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.3.1.1004/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.3.1.1004/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.3.1.1006/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.3.1.1006/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.3.1.1006/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.4.0.1284/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.4.0.1284/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.4.0.1284/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.4.0.1293/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.4.0.1293/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.4.0.1293/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.0.1298/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.0.1298/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.0.1298/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.1.1002/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.1.1002/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.1.1002/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.3.1001/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.3.1001/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.3.1001/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.4.1002/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.4.1002/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.4.1002/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.4.1007/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.4.1007/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.4.1007/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.5.1009/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.5.1009/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.5.1009/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.6.1014/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.6.1014/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.6.1014/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.7.1000/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.7.1000/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.5.7.1000/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.6.0.1156/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.6.0.1156/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.6.0.1156/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.6.1.1166/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.6.1.1166/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.6.1.1166/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.7.1.1020/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.7.1.1020/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.7.1.1020/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.7.2.1037/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.7.2.1037/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.7.2.1037/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.7.2.1043/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.7.2.1043/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/6.7.2.1043/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.0.1057/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.0.1057/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.0.1057/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.1.1002/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.1.1002/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.1.1002/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.1.1013/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.1.1013/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.1.1013/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.2.1014/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.2.1014/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.2.1014/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.2.1015/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.2.1015/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.2.1015/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.2.1016/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.2.1016/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.0.2.1016/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.4.1.8079/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.4.1.8079/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.4.1.8079/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.4.1.8091/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.4.1.8091/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.4.1.8091/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.4.1.8092/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.4.1.8092/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.4.1.8092/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.5.1.7010/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.5.1.7010/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.5.1.7010/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.5.1.7012/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.5.1.7012/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.5.1.7012/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.5.1.7013/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.5.1.7013/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.5.1.7013/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.5.2.1002/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.5.2.1002/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.5.2.1002/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.5.3.1000/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.5.3.1000/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/7.5.3.1000/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/8.0.0.1089/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/8.0.0.1089/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/8.0.0.1089/main/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/8.0.1.1029/ad/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/8.0.1.1029/ldap/kaniko-build.py delete mode 100644 linux/ecosystem/testrail/8.0.1.1029/main/kaniko-build.py delete mode 100644 linux/ecosystem/torrserver/kaniko-build.py delete mode 100644 linux/ecosystem/torrust-index/kaniko-build.py delete mode 100644 linux/ecosystem/torrust-tracker/kaniko-build.py delete mode 100644 linux/ecosystem/vk2discord/kaniko-build.py diff --git a/bin/ansible/roles/atlassian.bitbucket/files/Makefile b/bin/ansible/roles/atlassian.bitbucket/files/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/atlassian.bitbucket/files/Makefile +++ b/bin/ansible/roles/atlassian.bitbucket/files/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/atlassian.bitbucket/files/kaniko-build.py b/bin/ansible/roles/atlassian.bitbucket/files/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/atlassian.bitbucket/files/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/atlassian.jira/files/Makefile b/bin/ansible/roles/atlassian.jira/files/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/atlassian.jira/files/Makefile +++ b/bin/ansible/roles/atlassian.jira/files/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/atlassian.jira/files/kaniko-build.py b/bin/ansible/roles/atlassian.jira/files/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/atlassian.jira/files/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/gurock.testrail/files/php70/ad/Makefile b/bin/ansible/roles/gurock.testrail/files/php70/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/gurock.testrail/files/php70/ad/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php70/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/gurock.testrail/files/php70/ad/kaniko-build.py b/bin/ansible/roles/gurock.testrail/files/php70/ad/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/gurock.testrail/files/php70/ad/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/gurock.testrail/files/php70/ldap/Makefile b/bin/ansible/roles/gurock.testrail/files/php70/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/gurock.testrail/files/php70/ldap/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php70/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/gurock.testrail/files/php70/ldap/kaniko-build.py b/bin/ansible/roles/gurock.testrail/files/php70/ldap/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/gurock.testrail/files/php70/ldap/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/gurock.testrail/files/php70/main/Makefile b/bin/ansible/roles/gurock.testrail/files/php70/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/gurock.testrail/files/php70/main/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php70/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/gurock.testrail/files/php70/main/kaniko-build.py b/bin/ansible/roles/gurock.testrail/files/php70/main/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/gurock.testrail/files/php70/main/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/gurock.testrail/files/php71/ad/Makefile b/bin/ansible/roles/gurock.testrail/files/php71/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/gurock.testrail/files/php71/ad/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php71/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/gurock.testrail/files/php71/ad/kaniko-build.py b/bin/ansible/roles/gurock.testrail/files/php71/ad/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/gurock.testrail/files/php71/ad/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/gurock.testrail/files/php71/ldap/Makefile b/bin/ansible/roles/gurock.testrail/files/php71/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/gurock.testrail/files/php71/ldap/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php71/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/gurock.testrail/files/php71/ldap/kaniko-build.py b/bin/ansible/roles/gurock.testrail/files/php71/ldap/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/gurock.testrail/files/php71/ldap/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/gurock.testrail/files/php71/main/Makefile b/bin/ansible/roles/gurock.testrail/files/php71/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/gurock.testrail/files/php71/main/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php71/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/gurock.testrail/files/php71/main/kaniko-build.py b/bin/ansible/roles/gurock.testrail/files/php71/main/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/gurock.testrail/files/php71/main/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/gurock.testrail/files/php72/ad/Makefile b/bin/ansible/roles/gurock.testrail/files/php72/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/gurock.testrail/files/php72/ad/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php72/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/gurock.testrail/files/php72/ad/kaniko-build.py b/bin/ansible/roles/gurock.testrail/files/php72/ad/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/gurock.testrail/files/php72/ad/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/gurock.testrail/files/php72/ldap/Makefile b/bin/ansible/roles/gurock.testrail/files/php72/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/gurock.testrail/files/php72/ldap/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php72/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/gurock.testrail/files/php72/ldap/kaniko-build.py b/bin/ansible/roles/gurock.testrail/files/php72/ldap/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/gurock.testrail/files/php72/ldap/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/gurock.testrail/files/php72/main/Makefile b/bin/ansible/roles/gurock.testrail/files/php72/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/gurock.testrail/files/php72/main/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php72/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/gurock.testrail/files/php72/main/kaniko-build.py b/bin/ansible/roles/gurock.testrail/files/php72/main/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/gurock.testrail/files/php72/main/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/gurock.testrail/files/php74/ad/Makefile b/bin/ansible/roles/gurock.testrail/files/php74/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/gurock.testrail/files/php74/ad/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php74/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/gurock.testrail/files/php74/ad/kaniko-build.py b/bin/ansible/roles/gurock.testrail/files/php74/ad/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/gurock.testrail/files/php74/ad/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/gurock.testrail/files/php74/ldap/Makefile b/bin/ansible/roles/gurock.testrail/files/php74/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/gurock.testrail/files/php74/ldap/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php74/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/gurock.testrail/files/php74/ldap/kaniko-build.py b/bin/ansible/roles/gurock.testrail/files/php74/ldap/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/gurock.testrail/files/php74/ldap/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/gurock.testrail/files/php74/main/Makefile b/bin/ansible/roles/gurock.testrail/files/php74/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/gurock.testrail/files/php74/main/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php74/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/gurock.testrail/files/php74/main/kaniko-build.py b/bin/ansible/roles/gurock.testrail/files/php74/main/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/gurock.testrail/files/php74/main/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/gurock.testrail/files/php81/ad/Makefile b/bin/ansible/roles/gurock.testrail/files/php81/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/gurock.testrail/files/php81/ad/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php81/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/gurock.testrail/files/php81/ad/kaniko-build.py b/bin/ansible/roles/gurock.testrail/files/php81/ad/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/gurock.testrail/files/php81/ad/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/gurock.testrail/files/php81/ldap/Makefile b/bin/ansible/roles/gurock.testrail/files/php81/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/gurock.testrail/files/php81/ldap/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php81/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/gurock.testrail/files/php81/ldap/kaniko-build.py b/bin/ansible/roles/gurock.testrail/files/php81/ldap/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/gurock.testrail/files/php81/ldap/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/ansible/roles/gurock.testrail/files/php81/main/Makefile b/bin/ansible/roles/gurock.testrail/files/php81/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/bin/ansible/roles/gurock.testrail/files/php81/main/Makefile +++ b/bin/ansible/roles/gurock.testrail/files/php81/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/bin/ansible/roles/gurock.testrail/files/php81/main/kaniko-build.py b/bin/ansible/roles/gurock.testrail/files/php81/main/kaniko-build.py deleted file mode 100644 index e2034145c..000000000 --- a/bin/ansible/roles/gurock.testrail/files/php81/main/kaniko-build.py +++ /dev/null @@ -1,194 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.0.1" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - try: - future.result() - except Exception as exc: - logging.error(f"Generated an exception: {exc}") - -if __name__ == '__main__': - main() diff --git a/bin/kaniko/_deploy.py b/bin/kaniko/_deploy.py index 8d874fc0a..0a8b640a8 100644 --- a/bin/kaniko/_deploy.py +++ b/bin/kaniko/_deploy.py @@ -27,7 +27,7 @@ def main(): ignore_directory = os.path.join(root_directory, 'win32') # List of files to copy - files_to_copy = ['kaniko-build.py', 'requirements.txt'] + files_to_copy = ['requirements.txt'] # Check if the source files exist in the script directory for file_name in files_to_copy: diff --git a/bin/kaniko/kaniko-build.py b/bin/kaniko/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/bin/kaniko/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/bin/kaniko/requirements.txt b/bin/kaniko/requirements.txt index 9ed771861..568608d59 100644 --- a/bin/kaniko/requirements.txt +++ b/bin/kaniko/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/mattermost/Makefile b/linux/advanced/mattermost/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/mattermost/Makefile +++ b/linux/advanced/mattermost/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/mattermost/kaniko-build.py b/linux/advanced/mattermost/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/mattermost/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/mattermost/requirements.txt b/linux/advanced/mattermost/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/mattermost/requirements.txt +++ b/linux/advanced/mattermost/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/14/Makefile b/linux/advanced/nextcloud/patched/14/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/14/Makefile +++ b/linux/advanced/nextcloud/patched/14/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/14/kaniko-build.py b/linux/advanced/nextcloud/patched/14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/14/requirements.txt b/linux/advanced/nextcloud/patched/14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/14/requirements.txt +++ b/linux/advanced/nextcloud/patched/14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/15/Makefile b/linux/advanced/nextcloud/patched/15/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/15/Makefile +++ b/linux/advanced/nextcloud/patched/15/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/15/kaniko-build.py b/linux/advanced/nextcloud/patched/15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/15/requirements.txt b/linux/advanced/nextcloud/patched/15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/15/requirements.txt +++ b/linux/advanced/nextcloud/patched/15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/16/Makefile b/linux/advanced/nextcloud/patched/16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/16/Makefile +++ b/linux/advanced/nextcloud/patched/16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/16/kaniko-build.py b/linux/advanced/nextcloud/patched/16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/16/requirements.txt b/linux/advanced/nextcloud/patched/16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/16/requirements.txt +++ b/linux/advanced/nextcloud/patched/16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/17/Makefile b/linux/advanced/nextcloud/patched/17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/17/Makefile +++ b/linux/advanced/nextcloud/patched/17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/17/kaniko-build.py b/linux/advanced/nextcloud/patched/17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/17/requirements.txt b/linux/advanced/nextcloud/patched/17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/17/requirements.txt +++ b/linux/advanced/nextcloud/patched/17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/18/Makefile b/linux/advanced/nextcloud/patched/18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/18/Makefile +++ b/linux/advanced/nextcloud/patched/18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/18/kaniko-build.py b/linux/advanced/nextcloud/patched/18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/18/requirements.txt b/linux/advanced/nextcloud/patched/18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/18/requirements.txt +++ b/linux/advanced/nextcloud/patched/18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/19/Makefile b/linux/advanced/nextcloud/patched/19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/19/Makefile +++ b/linux/advanced/nextcloud/patched/19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/19/kaniko-build.py b/linux/advanced/nextcloud/patched/19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/19/requirements.txt b/linux/advanced/nextcloud/patched/19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/19/requirements.txt +++ b/linux/advanced/nextcloud/patched/19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/20/Makefile b/linux/advanced/nextcloud/patched/20/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/20/Makefile +++ b/linux/advanced/nextcloud/patched/20/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/20/kaniko-build.py b/linux/advanced/nextcloud/patched/20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/20/requirements.txt b/linux/advanced/nextcloud/patched/20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/20/requirements.txt +++ b/linux/advanced/nextcloud/patched/20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/21/Makefile b/linux/advanced/nextcloud/patched/21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/21/Makefile +++ b/linux/advanced/nextcloud/patched/21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/21/kaniko-build.py b/linux/advanced/nextcloud/patched/21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/21/requirements.txt b/linux/advanced/nextcloud/patched/21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/21/requirements.txt +++ b/linux/advanced/nextcloud/patched/21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/22/Makefile b/linux/advanced/nextcloud/patched/22/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/22/Makefile +++ b/linux/advanced/nextcloud/patched/22/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/22/kaniko-build.py b/linux/advanced/nextcloud/patched/22/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/22/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/22/requirements.txt b/linux/advanced/nextcloud/patched/22/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/22/requirements.txt +++ b/linux/advanced/nextcloud/patched/22/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/23/Makefile b/linux/advanced/nextcloud/patched/23/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/23/Makefile +++ b/linux/advanced/nextcloud/patched/23/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/23/kaniko-build.py b/linux/advanced/nextcloud/patched/23/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/23/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/23/requirements.txt b/linux/advanced/nextcloud/patched/23/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/23/requirements.txt +++ b/linux/advanced/nextcloud/patched/23/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/24/Makefile b/linux/advanced/nextcloud/patched/24/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/24/Makefile +++ b/linux/advanced/nextcloud/patched/24/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/24/kaniko-build.py b/linux/advanced/nextcloud/patched/24/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/24/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/24/requirements.txt b/linux/advanced/nextcloud/patched/24/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/24/requirements.txt +++ b/linux/advanced/nextcloud/patched/24/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/25/Makefile b/linux/advanced/nextcloud/patched/25/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/25/Makefile +++ b/linux/advanced/nextcloud/patched/25/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/25/kaniko-build.py b/linux/advanced/nextcloud/patched/25/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/25/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/25/requirements.txt b/linux/advanced/nextcloud/patched/25/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/25/requirements.txt +++ b/linux/advanced/nextcloud/patched/25/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/26/Makefile b/linux/advanced/nextcloud/patched/26/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/26/Makefile +++ b/linux/advanced/nextcloud/patched/26/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/26/kaniko-build.py b/linux/advanced/nextcloud/patched/26/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/26/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/26/requirements.txt b/linux/advanced/nextcloud/patched/26/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/26/requirements.txt +++ b/linux/advanced/nextcloud/patched/26/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/27/Makefile b/linux/advanced/nextcloud/patched/27/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/27/Makefile +++ b/linux/advanced/nextcloud/patched/27/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/27/kaniko-build.py b/linux/advanced/nextcloud/patched/27/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/27/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/27/requirements.txt b/linux/advanced/nextcloud/patched/27/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/27/requirements.txt +++ b/linux/advanced/nextcloud/patched/27/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/28/Makefile b/linux/advanced/nextcloud/patched/28/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/28/Makefile +++ b/linux/advanced/nextcloud/patched/28/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/28/kaniko-build.py b/linux/advanced/nextcloud/patched/28/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/28/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/28/requirements.txt b/linux/advanced/nextcloud/patched/28/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/28/requirements.txt +++ b/linux/advanced/nextcloud/patched/28/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/29/Makefile b/linux/advanced/nextcloud/patched/29/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/29/Makefile +++ b/linux/advanced/nextcloud/patched/29/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/29/kaniko-build.py b/linux/advanced/nextcloud/patched/29/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/29/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/29/requirements.txt b/linux/advanced/nextcloud/patched/29/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/29/requirements.txt +++ b/linux/advanced/nextcloud/patched/29/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/patched/latest/Makefile b/linux/advanced/nextcloud/patched/latest/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/patched/latest/Makefile +++ b/linux/advanced/nextcloud/patched/latest/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/patched/latest/kaniko-build.py b/linux/advanced/nextcloud/patched/latest/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/patched/latest/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/patched/latest/requirements.txt b/linux/advanced/nextcloud/patched/latest/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/patched/latest/requirements.txt +++ b/linux/advanced/nextcloud/patched/latest/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/14/Makefile b/linux/advanced/nextcloud/pure/14/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/14/Makefile +++ b/linux/advanced/nextcloud/pure/14/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/14/kaniko-build.py b/linux/advanced/nextcloud/pure/14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/14/requirements.txt b/linux/advanced/nextcloud/pure/14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/14/requirements.txt +++ b/linux/advanced/nextcloud/pure/14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/15/Makefile b/linux/advanced/nextcloud/pure/15/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/15/Makefile +++ b/linux/advanced/nextcloud/pure/15/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/15/kaniko-build.py b/linux/advanced/nextcloud/pure/15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/15/requirements.txt b/linux/advanced/nextcloud/pure/15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/15/requirements.txt +++ b/linux/advanced/nextcloud/pure/15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/16/Makefile b/linux/advanced/nextcloud/pure/16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/16/Makefile +++ b/linux/advanced/nextcloud/pure/16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/16/kaniko-build.py b/linux/advanced/nextcloud/pure/16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/16/requirements.txt b/linux/advanced/nextcloud/pure/16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/16/requirements.txt +++ b/linux/advanced/nextcloud/pure/16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/17/Makefile b/linux/advanced/nextcloud/pure/17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/17/Makefile +++ b/linux/advanced/nextcloud/pure/17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/17/kaniko-build.py b/linux/advanced/nextcloud/pure/17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/17/requirements.txt b/linux/advanced/nextcloud/pure/17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/17/requirements.txt +++ b/linux/advanced/nextcloud/pure/17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/18/Makefile b/linux/advanced/nextcloud/pure/18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/18/Makefile +++ b/linux/advanced/nextcloud/pure/18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/18/kaniko-build.py b/linux/advanced/nextcloud/pure/18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/18/requirements.txt b/linux/advanced/nextcloud/pure/18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/18/requirements.txt +++ b/linux/advanced/nextcloud/pure/18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/19/Makefile b/linux/advanced/nextcloud/pure/19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/19/Makefile +++ b/linux/advanced/nextcloud/pure/19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/19/kaniko-build.py b/linux/advanced/nextcloud/pure/19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/19/requirements.txt b/linux/advanced/nextcloud/pure/19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/19/requirements.txt +++ b/linux/advanced/nextcloud/pure/19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/20/Makefile b/linux/advanced/nextcloud/pure/20/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/20/Makefile +++ b/linux/advanced/nextcloud/pure/20/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/20/kaniko-build.py b/linux/advanced/nextcloud/pure/20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/20/requirements.txt b/linux/advanced/nextcloud/pure/20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/20/requirements.txt +++ b/linux/advanced/nextcloud/pure/20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/21/Makefile b/linux/advanced/nextcloud/pure/21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/21/Makefile +++ b/linux/advanced/nextcloud/pure/21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/21/kaniko-build.py b/linux/advanced/nextcloud/pure/21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/21/requirements.txt b/linux/advanced/nextcloud/pure/21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/21/requirements.txt +++ b/linux/advanced/nextcloud/pure/21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/22/Makefile b/linux/advanced/nextcloud/pure/22/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/22/Makefile +++ b/linux/advanced/nextcloud/pure/22/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/22/kaniko-build.py b/linux/advanced/nextcloud/pure/22/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/22/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/22/requirements.txt b/linux/advanced/nextcloud/pure/22/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/22/requirements.txt +++ b/linux/advanced/nextcloud/pure/22/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/23/Makefile b/linux/advanced/nextcloud/pure/23/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/23/Makefile +++ b/linux/advanced/nextcloud/pure/23/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/23/kaniko-build.py b/linux/advanced/nextcloud/pure/23/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/23/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/23/requirements.txt b/linux/advanced/nextcloud/pure/23/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/23/requirements.txt +++ b/linux/advanced/nextcloud/pure/23/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/24/Makefile b/linux/advanced/nextcloud/pure/24/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/24/Makefile +++ b/linux/advanced/nextcloud/pure/24/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/24/kaniko-build.py b/linux/advanced/nextcloud/pure/24/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/24/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/24/requirements.txt b/linux/advanced/nextcloud/pure/24/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/24/requirements.txt +++ b/linux/advanced/nextcloud/pure/24/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/25/Makefile b/linux/advanced/nextcloud/pure/25/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/25/Makefile +++ b/linux/advanced/nextcloud/pure/25/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/25/kaniko-build.py b/linux/advanced/nextcloud/pure/25/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/25/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/25/requirements.txt b/linux/advanced/nextcloud/pure/25/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/25/requirements.txt +++ b/linux/advanced/nextcloud/pure/25/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/26/Makefile b/linux/advanced/nextcloud/pure/26/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/26/Makefile +++ b/linux/advanced/nextcloud/pure/26/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/26/kaniko-build.py b/linux/advanced/nextcloud/pure/26/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/26/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/26/requirements.txt b/linux/advanced/nextcloud/pure/26/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/26/requirements.txt +++ b/linux/advanced/nextcloud/pure/26/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/27/Makefile b/linux/advanced/nextcloud/pure/27/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/27/Makefile +++ b/linux/advanced/nextcloud/pure/27/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/27/kaniko-build.py b/linux/advanced/nextcloud/pure/27/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/27/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/27/requirements.txt b/linux/advanced/nextcloud/pure/27/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/27/requirements.txt +++ b/linux/advanced/nextcloud/pure/27/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/28/Makefile b/linux/advanced/nextcloud/pure/28/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/28/Makefile +++ b/linux/advanced/nextcloud/pure/28/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/28/kaniko-build.py b/linux/advanced/nextcloud/pure/28/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/28/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/28/requirements.txt b/linux/advanced/nextcloud/pure/28/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/28/requirements.txt +++ b/linux/advanced/nextcloud/pure/28/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/29/Makefile b/linux/advanced/nextcloud/pure/29/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/29/Makefile +++ b/linux/advanced/nextcloud/pure/29/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/29/kaniko-build.py b/linux/advanced/nextcloud/pure/29/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/29/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/29/requirements.txt b/linux/advanced/nextcloud/pure/29/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/29/requirements.txt +++ b/linux/advanced/nextcloud/pure/29/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/nextcloud/pure/latest/Makefile b/linux/advanced/nextcloud/pure/latest/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/nextcloud/pure/latest/Makefile +++ b/linux/advanced/nextcloud/pure/latest/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/nextcloud/pure/latest/kaniko-build.py b/linux/advanced/nextcloud/pure/latest/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/nextcloud/pure/latest/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/nextcloud/pure/latest/requirements.txt b/linux/advanced/nextcloud/pure/latest/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/nextcloud/pure/latest/requirements.txt +++ b/linux/advanced/nextcloud/pure/latest/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/develop/2.7/Makefile b/linux/advanced/python/develop/2.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/develop/2.7/Makefile +++ b/linux/advanced/python/develop/2.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/develop/2.7/kaniko-build.py b/linux/advanced/python/develop/2.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/develop/2.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/develop/2.7/requirements.txt b/linux/advanced/python/develop/2.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/develop/2.7/requirements.txt +++ b/linux/advanced/python/develop/2.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/develop/3.10/Makefile b/linux/advanced/python/develop/3.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/develop/3.10/Makefile +++ b/linux/advanced/python/develop/3.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/develop/3.10/kaniko-build.py b/linux/advanced/python/develop/3.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/develop/3.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/develop/3.10/requirements.txt b/linux/advanced/python/develop/3.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/develop/3.10/requirements.txt +++ b/linux/advanced/python/develop/3.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/develop/3.11/Makefile b/linux/advanced/python/develop/3.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/develop/3.11/Makefile +++ b/linux/advanced/python/develop/3.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/develop/3.11/kaniko-build.py b/linux/advanced/python/develop/3.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/develop/3.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/develop/3.11/requirements.txt b/linux/advanced/python/develop/3.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/develop/3.11/requirements.txt +++ b/linux/advanced/python/develop/3.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/develop/3.12/Makefile b/linux/advanced/python/develop/3.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/develop/3.12/Makefile +++ b/linux/advanced/python/develop/3.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/develop/3.12/kaniko-build.py b/linux/advanced/python/develop/3.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/develop/3.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/develop/3.12/requirements.txt b/linux/advanced/python/develop/3.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/develop/3.12/requirements.txt +++ b/linux/advanced/python/develop/3.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/develop/3.13/Makefile b/linux/advanced/python/develop/3.13/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/develop/3.13/Makefile +++ b/linux/advanced/python/develop/3.13/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/develop/3.13/kaniko-build.py b/linux/advanced/python/develop/3.13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/develop/3.13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/develop/3.13/requirements.txt b/linux/advanced/python/develop/3.13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/develop/3.13/requirements.txt +++ b/linux/advanced/python/develop/3.13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/develop/3.6/Makefile b/linux/advanced/python/develop/3.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/develop/3.6/Makefile +++ b/linux/advanced/python/develop/3.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/develop/3.6/kaniko-build.py b/linux/advanced/python/develop/3.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/develop/3.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/develop/3.6/requirements.txt b/linux/advanced/python/develop/3.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/develop/3.6/requirements.txt +++ b/linux/advanced/python/develop/3.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/develop/3.7/Makefile b/linux/advanced/python/develop/3.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/develop/3.7/Makefile +++ b/linux/advanced/python/develop/3.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/develop/3.7/kaniko-build.py b/linux/advanced/python/develop/3.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/develop/3.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/develop/3.7/requirements.txt b/linux/advanced/python/develop/3.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/develop/3.7/requirements.txt +++ b/linux/advanced/python/develop/3.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/develop/3.8/Makefile b/linux/advanced/python/develop/3.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/develop/3.8/Makefile +++ b/linux/advanced/python/develop/3.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/develop/3.8/kaniko-build.py b/linux/advanced/python/develop/3.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/develop/3.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/develop/3.8/requirements.txt b/linux/advanced/python/develop/3.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/develop/3.8/requirements.txt +++ b/linux/advanced/python/develop/3.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/develop/3.9/Makefile b/linux/advanced/python/develop/3.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/develop/3.9/Makefile +++ b/linux/advanced/python/develop/3.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/develop/3.9/kaniko-build.py b/linux/advanced/python/develop/3.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/develop/3.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/develop/3.9/requirements.txt b/linux/advanced/python/develop/3.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/develop/3.9/requirements.txt +++ b/linux/advanced/python/develop/3.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/main/2.7/Makefile b/linux/advanced/python/main/2.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/main/2.7/Makefile +++ b/linux/advanced/python/main/2.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/main/2.7/kaniko-build.py b/linux/advanced/python/main/2.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/main/2.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/main/2.7/requirements.txt b/linux/advanced/python/main/2.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/main/2.7/requirements.txt +++ b/linux/advanced/python/main/2.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/main/3.10/Makefile b/linux/advanced/python/main/3.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/main/3.10/Makefile +++ b/linux/advanced/python/main/3.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/main/3.10/kaniko-build.py b/linux/advanced/python/main/3.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/main/3.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/main/3.10/requirements.txt b/linux/advanced/python/main/3.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/main/3.10/requirements.txt +++ b/linux/advanced/python/main/3.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/main/3.11/Makefile b/linux/advanced/python/main/3.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/main/3.11/Makefile +++ b/linux/advanced/python/main/3.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/main/3.11/kaniko-build.py b/linux/advanced/python/main/3.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/main/3.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/main/3.11/requirements.txt b/linux/advanced/python/main/3.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/main/3.11/requirements.txt +++ b/linux/advanced/python/main/3.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/main/3.12/Makefile b/linux/advanced/python/main/3.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/main/3.12/Makefile +++ b/linux/advanced/python/main/3.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/main/3.12/kaniko-build.py b/linux/advanced/python/main/3.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/main/3.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/main/3.12/requirements.txt b/linux/advanced/python/main/3.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/main/3.12/requirements.txt +++ b/linux/advanced/python/main/3.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/main/3.13/Makefile b/linux/advanced/python/main/3.13/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/main/3.13/Makefile +++ b/linux/advanced/python/main/3.13/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/main/3.13/kaniko-build.py b/linux/advanced/python/main/3.13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/main/3.13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/main/3.13/requirements.txt b/linux/advanced/python/main/3.13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/main/3.13/requirements.txt +++ b/linux/advanced/python/main/3.13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/main/3.6/Makefile b/linux/advanced/python/main/3.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/main/3.6/Makefile +++ b/linux/advanced/python/main/3.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/main/3.6/kaniko-build.py b/linux/advanced/python/main/3.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/main/3.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/main/3.6/requirements.txt b/linux/advanced/python/main/3.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/main/3.6/requirements.txt +++ b/linux/advanced/python/main/3.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/main/3.7/Makefile b/linux/advanced/python/main/3.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/main/3.7/Makefile +++ b/linux/advanced/python/main/3.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/main/3.7/kaniko-build.py b/linux/advanced/python/main/3.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/main/3.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/main/3.7/requirements.txt b/linux/advanced/python/main/3.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/main/3.7/requirements.txt +++ b/linux/advanced/python/main/3.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/main/3.8/Makefile b/linux/advanced/python/main/3.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/main/3.8/Makefile +++ b/linux/advanced/python/main/3.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/main/3.8/kaniko-build.py b/linux/advanced/python/main/3.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/main/3.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/main/3.8/requirements.txt b/linux/advanced/python/main/3.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/main/3.8/requirements.txt +++ b/linux/advanced/python/main/3.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/python/main/3.9/Makefile b/linux/advanced/python/main/3.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/python/main/3.9/Makefile +++ b/linux/advanced/python/main/3.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/python/main/3.9/kaniko-build.py b/linux/advanced/python/main/3.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/python/main/3.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/python/main/3.9/requirements.txt b/linux/advanced/python/main/3.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/python/main/3.9/requirements.txt +++ b/linux/advanced/python/main/3.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/redash/Makefile b/linux/advanced/redash/Makefile index 5927219c1..c7062c47e 100644 --- a/linux/advanced/redash/Makefile +++ b/linux/advanced/redash/Makefile @@ -20,7 +20,7 @@ patch: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -29,7 +29,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -48,7 +48,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/sentry/latest/Makefile b/linux/advanced/sentry/latest/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/sentry/latest/Makefile +++ b/linux/advanced/sentry/latest/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/sentry/latest/kaniko-build.py b/linux/advanced/sentry/latest/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/sentry/latest/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/sentry/latest/requirements.txt b/linux/advanced/sentry/latest/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/sentry/latest/requirements.txt +++ b/linux/advanced/sentry/latest/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/teamcity/server/Makefile b/linux/advanced/teamcity/server/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/teamcity/server/Makefile +++ b/linux/advanced/teamcity/server/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/teamcity/server/kaniko-build.py b/linux/advanced/teamcity/server/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/teamcity/server/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/teamcity/server/requirements.txt b/linux/advanced/teamcity/server/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/teamcity/server/requirements.txt +++ b/linux/advanced/teamcity/server/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/vscode-server/amxx/1.10/Makefile b/linux/advanced/vscode-server/amxx/1.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/vscode-server/amxx/1.10/Makefile +++ b/linux/advanced/vscode-server/amxx/1.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/vscode-server/amxx/1.10/kaniko-build.py b/linux/advanced/vscode-server/amxx/1.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/vscode-server/amxx/1.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/vscode-server/amxx/1.10/requirements.txt b/linux/advanced/vscode-server/amxx/1.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/vscode-server/amxx/1.10/requirements.txt +++ b/linux/advanced/vscode-server/amxx/1.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/vscode-server/amxx/1.9/Makefile b/linux/advanced/vscode-server/amxx/1.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/vscode-server/amxx/1.9/Makefile +++ b/linux/advanced/vscode-server/amxx/1.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/vscode-server/amxx/1.9/kaniko-build.py b/linux/advanced/vscode-server/amxx/1.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/vscode-server/amxx/1.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/vscode-server/amxx/1.9/requirements.txt b/linux/advanced/vscode-server/amxx/1.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/vscode-server/amxx/1.9/requirements.txt +++ b/linux/advanced/vscode-server/amxx/1.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/vscode-server/android/Makefile b/linux/advanced/vscode-server/android/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/vscode-server/android/Makefile +++ b/linux/advanced/vscode-server/android/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/vscode-server/android/kaniko-build.py b/linux/advanced/vscode-server/android/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/vscode-server/android/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/vscode-server/android/requirements.txt b/linux/advanced/vscode-server/android/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/vscode-server/android/requirements.txt +++ b/linux/advanced/vscode-server/android/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/vscode-server/cpp/Makefile b/linux/advanced/vscode-server/cpp/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/vscode-server/cpp/Makefile +++ b/linux/advanced/vscode-server/cpp/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/vscode-server/cpp/kaniko-build.py b/linux/advanced/vscode-server/cpp/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/vscode-server/cpp/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/vscode-server/cpp/requirements.txt b/linux/advanced/vscode-server/cpp/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/vscode-server/cpp/requirements.txt +++ b/linux/advanced/vscode-server/cpp/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/vscode-server/devops/Makefile b/linux/advanced/vscode-server/devops/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/vscode-server/devops/Makefile +++ b/linux/advanced/vscode-server/devops/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/vscode-server/devops/kaniko-build.py b/linux/advanced/vscode-server/devops/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/vscode-server/devops/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/vscode-server/devops/requirements.txt b/linux/advanced/vscode-server/devops/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/vscode-server/devops/requirements.txt +++ b/linux/advanced/vscode-server/devops/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/vscode-server/docker/Makefile b/linux/advanced/vscode-server/docker/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/vscode-server/docker/Makefile +++ b/linux/advanced/vscode-server/docker/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/vscode-server/docker/kaniko-build.py b/linux/advanced/vscode-server/docker/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/vscode-server/docker/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/vscode-server/docker/requirements.txt b/linux/advanced/vscode-server/docker/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/vscode-server/docker/requirements.txt +++ b/linux/advanced/vscode-server/docker/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/vscode-server/dotnet-full/Makefile b/linux/advanced/vscode-server/dotnet-full/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/vscode-server/dotnet-full/Makefile +++ b/linux/advanced/vscode-server/dotnet-full/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/vscode-server/dotnet-full/kaniko-build.py b/linux/advanced/vscode-server/dotnet-full/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/vscode-server/dotnet-full/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/vscode-server/dotnet-full/requirements.txt b/linux/advanced/vscode-server/dotnet-full/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/vscode-server/dotnet-full/requirements.txt +++ b/linux/advanced/vscode-server/dotnet-full/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/vscode-server/dotnet/Makefile b/linux/advanced/vscode-server/dotnet/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/vscode-server/dotnet/Makefile +++ b/linux/advanced/vscode-server/dotnet/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/vscode-server/dotnet/kaniko-build.py b/linux/advanced/vscode-server/dotnet/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/vscode-server/dotnet/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/vscode-server/dotnet/requirements.txt b/linux/advanced/vscode-server/dotnet/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/vscode-server/dotnet/requirements.txt +++ b/linux/advanced/vscode-server/dotnet/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/vscode-server/latest/Makefile b/linux/advanced/vscode-server/latest/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/vscode-server/latest/Makefile +++ b/linux/advanced/vscode-server/latest/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/vscode-server/latest/kaniko-build.py b/linux/advanced/vscode-server/latest/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/vscode-server/latest/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/vscode-server/latest/requirements.txt b/linux/advanced/vscode-server/latest/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/vscode-server/latest/requirements.txt +++ b/linux/advanced/vscode-server/latest/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/vscode-server/mono/Makefile b/linux/advanced/vscode-server/mono/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/vscode-server/mono/Makefile +++ b/linux/advanced/vscode-server/mono/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/vscode-server/mono/kaniko-build.py b/linux/advanced/vscode-server/mono/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/vscode-server/mono/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/vscode-server/mono/requirements.txt b/linux/advanced/vscode-server/mono/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/vscode-server/mono/requirements.txt +++ b/linux/advanced/vscode-server/mono/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/3.0/agent/Makefile b/linux/advanced/zabbix/3.0/agent/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/3.0/agent/Makefile +++ b/linux/advanced/zabbix/3.0/agent/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/3.0/agent/kaniko-build.py b/linux/advanced/zabbix/3.0/agent/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/3.0/agent/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/3.0/agent/requirements.txt b/linux/advanced/zabbix/3.0/agent/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/3.0/agent/requirements.txt +++ b/linux/advanced/zabbix/3.0/agent/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/3.0/java-gateway/Makefile b/linux/advanced/zabbix/3.0/java-gateway/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/3.0/java-gateway/Makefile +++ b/linux/advanced/zabbix/3.0/java-gateway/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/3.0/java-gateway/kaniko-build.py b/linux/advanced/zabbix/3.0/java-gateway/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/3.0/java-gateway/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/3.0/java-gateway/requirements.txt b/linux/advanced/zabbix/3.0/java-gateway/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/3.0/java-gateway/requirements.txt +++ b/linux/advanced/zabbix/3.0/java-gateway/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/3.0/proxy-mysql/Makefile b/linux/advanced/zabbix/3.0/proxy-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/3.0/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/3.0/proxy-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/3.0/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/3.0/proxy-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/3.0/proxy-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/3.0/proxy-mysql/requirements.txt b/linux/advanced/zabbix/3.0/proxy-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/3.0/proxy-mysql/requirements.txt +++ b/linux/advanced/zabbix/3.0/proxy-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/3.0/proxy-sqlite3/Makefile b/linux/advanced/zabbix/3.0/proxy-sqlite3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/3.0/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/3.0/proxy-sqlite3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/3.0/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/3.0/proxy-sqlite3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/3.0/proxy-sqlite3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/3.0/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/3.0/proxy-sqlite3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/3.0/proxy-sqlite3/requirements.txt +++ b/linux/advanced/zabbix/3.0/proxy-sqlite3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/3.0/server-mysql/Makefile b/linux/advanced/zabbix/3.0/server-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/3.0/server-mysql/Makefile +++ b/linux/advanced/zabbix/3.0/server-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/3.0/server-mysql/kaniko-build.py b/linux/advanced/zabbix/3.0/server-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/3.0/server-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/3.0/server-mysql/requirements.txt b/linux/advanced/zabbix/3.0/server-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/3.0/server-mysql/requirements.txt +++ b/linux/advanced/zabbix/3.0/server-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/3.0/server-pgsql/Makefile b/linux/advanced/zabbix/3.0/server-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/3.0/server-pgsql/Makefile +++ b/linux/advanced/zabbix/3.0/server-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/3.0/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/3.0/server-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/3.0/server-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/3.0/server-pgsql/requirements.txt b/linux/advanced/zabbix/3.0/server-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/3.0/server-pgsql/requirements.txt +++ b/linux/advanced/zabbix/3.0/server-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/3.0/snmptraps/Makefile b/linux/advanced/zabbix/3.0/snmptraps/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/3.0/snmptraps/Makefile +++ b/linux/advanced/zabbix/3.0/snmptraps/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/3.0/snmptraps/kaniko-build.py b/linux/advanced/zabbix/3.0/snmptraps/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/3.0/snmptraps/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/3.0/snmptraps/requirements.txt b/linux/advanced/zabbix/3.0/snmptraps/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/3.0/snmptraps/requirements.txt +++ b/linux/advanced/zabbix/3.0/snmptraps/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/3.0/web-mysql/Makefile b/linux/advanced/zabbix/3.0/web-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/3.0/web-mysql/Makefile +++ b/linux/advanced/zabbix/3.0/web-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/3.0/web-mysql/kaniko-build.py b/linux/advanced/zabbix/3.0/web-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/3.0/web-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/3.0/web-mysql/requirements.txt b/linux/advanced/zabbix/3.0/web-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/3.0/web-mysql/requirements.txt +++ b/linux/advanced/zabbix/3.0/web-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/3.0/web-pgsql/Makefile b/linux/advanced/zabbix/3.0/web-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/3.0/web-pgsql/Makefile +++ b/linux/advanced/zabbix/3.0/web-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/3.0/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/3.0/web-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/3.0/web-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/3.0/web-pgsql/requirements.txt b/linux/advanced/zabbix/3.0/web-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/3.0/web-pgsql/requirements.txt +++ b/linux/advanced/zabbix/3.0/web-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/4.0/agent/Makefile b/linux/advanced/zabbix/4.0/agent/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/4.0/agent/Makefile +++ b/linux/advanced/zabbix/4.0/agent/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/4.0/agent/kaniko-build.py b/linux/advanced/zabbix/4.0/agent/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/4.0/agent/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/4.0/agent/requirements.txt b/linux/advanced/zabbix/4.0/agent/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/4.0/agent/requirements.txt +++ b/linux/advanced/zabbix/4.0/agent/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/4.0/java-gateway/Makefile b/linux/advanced/zabbix/4.0/java-gateway/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/4.0/java-gateway/Makefile +++ b/linux/advanced/zabbix/4.0/java-gateway/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/4.0/java-gateway/kaniko-build.py b/linux/advanced/zabbix/4.0/java-gateway/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/4.0/java-gateway/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/4.0/java-gateway/requirements.txt b/linux/advanced/zabbix/4.0/java-gateway/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/4.0/java-gateway/requirements.txt +++ b/linux/advanced/zabbix/4.0/java-gateway/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/4.0/proxy-mysql/Makefile b/linux/advanced/zabbix/4.0/proxy-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/4.0/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/4.0/proxy-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/4.0/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/4.0/proxy-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/4.0/proxy-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/4.0/proxy-mysql/requirements.txt b/linux/advanced/zabbix/4.0/proxy-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/4.0/proxy-mysql/requirements.txt +++ b/linux/advanced/zabbix/4.0/proxy-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/4.0/proxy-sqlite3/Makefile b/linux/advanced/zabbix/4.0/proxy-sqlite3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/4.0/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/4.0/proxy-sqlite3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/4.0/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/4.0/proxy-sqlite3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/4.0/proxy-sqlite3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/4.0/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/4.0/proxy-sqlite3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/4.0/proxy-sqlite3/requirements.txt +++ b/linux/advanced/zabbix/4.0/proxy-sqlite3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/4.0/server-mysql/Makefile b/linux/advanced/zabbix/4.0/server-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/4.0/server-mysql/Makefile +++ b/linux/advanced/zabbix/4.0/server-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/4.0/server-mysql/kaniko-build.py b/linux/advanced/zabbix/4.0/server-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/4.0/server-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/4.0/server-mysql/requirements.txt b/linux/advanced/zabbix/4.0/server-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/4.0/server-mysql/requirements.txt +++ b/linux/advanced/zabbix/4.0/server-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/4.0/server-pgsql/Makefile b/linux/advanced/zabbix/4.0/server-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/4.0/server-pgsql/Makefile +++ b/linux/advanced/zabbix/4.0/server-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/4.0/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/4.0/server-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/4.0/server-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/4.0/server-pgsql/requirements.txt b/linux/advanced/zabbix/4.0/server-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/4.0/server-pgsql/requirements.txt +++ b/linux/advanced/zabbix/4.0/server-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/4.0/snmptraps/Makefile b/linux/advanced/zabbix/4.0/snmptraps/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/4.0/snmptraps/Makefile +++ b/linux/advanced/zabbix/4.0/snmptraps/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/4.0/snmptraps/kaniko-build.py b/linux/advanced/zabbix/4.0/snmptraps/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/4.0/snmptraps/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/4.0/snmptraps/requirements.txt b/linux/advanced/zabbix/4.0/snmptraps/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/4.0/snmptraps/requirements.txt +++ b/linux/advanced/zabbix/4.0/snmptraps/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/4.0/web-mysql/Makefile b/linux/advanced/zabbix/4.0/web-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/4.0/web-mysql/Makefile +++ b/linux/advanced/zabbix/4.0/web-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/4.0/web-mysql/kaniko-build.py b/linux/advanced/zabbix/4.0/web-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/4.0/web-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/4.0/web-mysql/requirements.txt b/linux/advanced/zabbix/4.0/web-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/4.0/web-mysql/requirements.txt +++ b/linux/advanced/zabbix/4.0/web-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/4.0/web-pgsql/Makefile b/linux/advanced/zabbix/4.0/web-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/4.0/web-pgsql/Makefile +++ b/linux/advanced/zabbix/4.0/web-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/4.0/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/4.0/web-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/4.0/web-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/4.0/web-pgsql/requirements.txt b/linux/advanced/zabbix/4.0/web-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/4.0/web-pgsql/requirements.txt +++ b/linux/advanced/zabbix/4.0/web-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.0/agent/Makefile b/linux/advanced/zabbix/5.0/agent/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.0/agent/Makefile +++ b/linux/advanced/zabbix/5.0/agent/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.0/agent/kaniko-build.py b/linux/advanced/zabbix/5.0/agent/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.0/agent/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.0/agent/requirements.txt b/linux/advanced/zabbix/5.0/agent/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.0/agent/requirements.txt +++ b/linux/advanced/zabbix/5.0/agent/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.0/agent2/Makefile b/linux/advanced/zabbix/5.0/agent2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.0/agent2/Makefile +++ b/linux/advanced/zabbix/5.0/agent2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.0/agent2/kaniko-build.py b/linux/advanced/zabbix/5.0/agent2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.0/agent2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.0/agent2/requirements.txt b/linux/advanced/zabbix/5.0/agent2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.0/agent2/requirements.txt +++ b/linux/advanced/zabbix/5.0/agent2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.0/java-gateway/Makefile b/linux/advanced/zabbix/5.0/java-gateway/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.0/java-gateway/Makefile +++ b/linux/advanced/zabbix/5.0/java-gateway/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.0/java-gateway/kaniko-build.py b/linux/advanced/zabbix/5.0/java-gateway/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.0/java-gateway/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.0/java-gateway/requirements.txt b/linux/advanced/zabbix/5.0/java-gateway/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.0/java-gateway/requirements.txt +++ b/linux/advanced/zabbix/5.0/java-gateway/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.0/proxy-mysql/Makefile b/linux/advanced/zabbix/5.0/proxy-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.0/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/5.0/proxy-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.0/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/5.0/proxy-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.0/proxy-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.0/proxy-mysql/requirements.txt b/linux/advanced/zabbix/5.0/proxy-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.0/proxy-mysql/requirements.txt +++ b/linux/advanced/zabbix/5.0/proxy-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.0/proxy-sqlite3/Makefile b/linux/advanced/zabbix/5.0/proxy-sqlite3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.0/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/5.0/proxy-sqlite3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.0/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/5.0/proxy-sqlite3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.0/proxy-sqlite3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.0/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/5.0/proxy-sqlite3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.0/proxy-sqlite3/requirements.txt +++ b/linux/advanced/zabbix/5.0/proxy-sqlite3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.0/server-mysql/Makefile b/linux/advanced/zabbix/5.0/server-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.0/server-mysql/Makefile +++ b/linux/advanced/zabbix/5.0/server-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.0/server-mysql/kaniko-build.py b/linux/advanced/zabbix/5.0/server-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.0/server-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.0/server-mysql/requirements.txt b/linux/advanced/zabbix/5.0/server-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.0/server-mysql/requirements.txt +++ b/linux/advanced/zabbix/5.0/server-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.0/server-pgsql/Makefile b/linux/advanced/zabbix/5.0/server-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.0/server-pgsql/Makefile +++ b/linux/advanced/zabbix/5.0/server-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.0/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/5.0/server-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.0/server-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.0/server-pgsql/requirements.txt b/linux/advanced/zabbix/5.0/server-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.0/server-pgsql/requirements.txt +++ b/linux/advanced/zabbix/5.0/server-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.0/snmptraps/Makefile b/linux/advanced/zabbix/5.0/snmptraps/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.0/snmptraps/Makefile +++ b/linux/advanced/zabbix/5.0/snmptraps/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.0/snmptraps/kaniko-build.py b/linux/advanced/zabbix/5.0/snmptraps/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.0/snmptraps/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.0/snmptraps/requirements.txt b/linux/advanced/zabbix/5.0/snmptraps/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.0/snmptraps/requirements.txt +++ b/linux/advanced/zabbix/5.0/snmptraps/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.0/web-mysql/Makefile b/linux/advanced/zabbix/5.0/web-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.0/web-mysql/Makefile +++ b/linux/advanced/zabbix/5.0/web-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.0/web-mysql/kaniko-build.py b/linux/advanced/zabbix/5.0/web-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.0/web-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.0/web-mysql/requirements.txt b/linux/advanced/zabbix/5.0/web-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.0/web-mysql/requirements.txt +++ b/linux/advanced/zabbix/5.0/web-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.0/web-pgsql/Makefile b/linux/advanced/zabbix/5.0/web-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.0/web-pgsql/Makefile +++ b/linux/advanced/zabbix/5.0/web-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.0/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/5.0/web-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.0/web-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.0/web-pgsql/requirements.txt b/linux/advanced/zabbix/5.0/web-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.0/web-pgsql/requirements.txt +++ b/linux/advanced/zabbix/5.0/web-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.2/agent/Makefile b/linux/advanced/zabbix/5.2/agent/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.2/agent/Makefile +++ b/linux/advanced/zabbix/5.2/agent/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.2/agent/kaniko-build.py b/linux/advanced/zabbix/5.2/agent/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.2/agent/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.2/agent/requirements.txt b/linux/advanced/zabbix/5.2/agent/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.2/agent/requirements.txt +++ b/linux/advanced/zabbix/5.2/agent/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.2/agent2/Makefile b/linux/advanced/zabbix/5.2/agent2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.2/agent2/Makefile +++ b/linux/advanced/zabbix/5.2/agent2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.2/agent2/kaniko-build.py b/linux/advanced/zabbix/5.2/agent2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.2/agent2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.2/agent2/requirements.txt b/linux/advanced/zabbix/5.2/agent2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.2/agent2/requirements.txt +++ b/linux/advanced/zabbix/5.2/agent2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.2/java-gateway/Makefile b/linux/advanced/zabbix/5.2/java-gateway/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.2/java-gateway/Makefile +++ b/linux/advanced/zabbix/5.2/java-gateway/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.2/java-gateway/kaniko-build.py b/linux/advanced/zabbix/5.2/java-gateway/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.2/java-gateway/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.2/java-gateway/requirements.txt b/linux/advanced/zabbix/5.2/java-gateway/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.2/java-gateway/requirements.txt +++ b/linux/advanced/zabbix/5.2/java-gateway/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.2/proxy-mysql/Makefile b/linux/advanced/zabbix/5.2/proxy-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.2/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/5.2/proxy-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.2/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/5.2/proxy-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.2/proxy-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.2/proxy-mysql/requirements.txt b/linux/advanced/zabbix/5.2/proxy-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.2/proxy-mysql/requirements.txt +++ b/linux/advanced/zabbix/5.2/proxy-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.2/proxy-sqlite3/Makefile b/linux/advanced/zabbix/5.2/proxy-sqlite3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.2/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/5.2/proxy-sqlite3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.2/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/5.2/proxy-sqlite3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.2/proxy-sqlite3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.2/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/5.2/proxy-sqlite3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.2/proxy-sqlite3/requirements.txt +++ b/linux/advanced/zabbix/5.2/proxy-sqlite3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.2/server-mysql/Makefile b/linux/advanced/zabbix/5.2/server-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.2/server-mysql/Makefile +++ b/linux/advanced/zabbix/5.2/server-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.2/server-mysql/kaniko-build.py b/linux/advanced/zabbix/5.2/server-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.2/server-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.2/server-mysql/requirements.txt b/linux/advanced/zabbix/5.2/server-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.2/server-mysql/requirements.txt +++ b/linux/advanced/zabbix/5.2/server-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.2/server-pgsql/Makefile b/linux/advanced/zabbix/5.2/server-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.2/server-pgsql/Makefile +++ b/linux/advanced/zabbix/5.2/server-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.2/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/5.2/server-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.2/server-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.2/server-pgsql/requirements.txt b/linux/advanced/zabbix/5.2/server-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.2/server-pgsql/requirements.txt +++ b/linux/advanced/zabbix/5.2/server-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.2/snmptraps/Makefile b/linux/advanced/zabbix/5.2/snmptraps/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.2/snmptraps/Makefile +++ b/linux/advanced/zabbix/5.2/snmptraps/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.2/snmptraps/kaniko-build.py b/linux/advanced/zabbix/5.2/snmptraps/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.2/snmptraps/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.2/snmptraps/requirements.txt b/linux/advanced/zabbix/5.2/snmptraps/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.2/snmptraps/requirements.txt +++ b/linux/advanced/zabbix/5.2/snmptraps/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.2/web-mysql/Makefile b/linux/advanced/zabbix/5.2/web-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.2/web-mysql/Makefile +++ b/linux/advanced/zabbix/5.2/web-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.2/web-mysql/kaniko-build.py b/linux/advanced/zabbix/5.2/web-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.2/web-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.2/web-mysql/requirements.txt b/linux/advanced/zabbix/5.2/web-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.2/web-mysql/requirements.txt +++ b/linux/advanced/zabbix/5.2/web-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.2/web-pgsql/Makefile b/linux/advanced/zabbix/5.2/web-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.2/web-pgsql/Makefile +++ b/linux/advanced/zabbix/5.2/web-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.2/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/5.2/web-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.2/web-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.2/web-pgsql/requirements.txt b/linux/advanced/zabbix/5.2/web-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.2/web-pgsql/requirements.txt +++ b/linux/advanced/zabbix/5.2/web-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.4/agent/Makefile b/linux/advanced/zabbix/5.4/agent/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.4/agent/Makefile +++ b/linux/advanced/zabbix/5.4/agent/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.4/agent/kaniko-build.py b/linux/advanced/zabbix/5.4/agent/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.4/agent/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.4/agent/requirements.txt b/linux/advanced/zabbix/5.4/agent/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.4/agent/requirements.txt +++ b/linux/advanced/zabbix/5.4/agent/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.4/agent2/Makefile b/linux/advanced/zabbix/5.4/agent2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.4/agent2/Makefile +++ b/linux/advanced/zabbix/5.4/agent2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.4/agent2/kaniko-build.py b/linux/advanced/zabbix/5.4/agent2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.4/agent2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.4/agent2/requirements.txt b/linux/advanced/zabbix/5.4/agent2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.4/agent2/requirements.txt +++ b/linux/advanced/zabbix/5.4/agent2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.4/java-gateway/Makefile b/linux/advanced/zabbix/5.4/java-gateway/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.4/java-gateway/Makefile +++ b/linux/advanced/zabbix/5.4/java-gateway/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.4/java-gateway/kaniko-build.py b/linux/advanced/zabbix/5.4/java-gateway/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.4/java-gateway/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.4/java-gateway/requirements.txt b/linux/advanced/zabbix/5.4/java-gateway/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.4/java-gateway/requirements.txt +++ b/linux/advanced/zabbix/5.4/java-gateway/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.4/proxy-mysql/Makefile b/linux/advanced/zabbix/5.4/proxy-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.4/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/5.4/proxy-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.4/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/5.4/proxy-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.4/proxy-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.4/proxy-mysql/requirements.txt b/linux/advanced/zabbix/5.4/proxy-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.4/proxy-mysql/requirements.txt +++ b/linux/advanced/zabbix/5.4/proxy-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.4/proxy-sqlite3/Makefile b/linux/advanced/zabbix/5.4/proxy-sqlite3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.4/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/5.4/proxy-sqlite3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.4/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/5.4/proxy-sqlite3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.4/proxy-sqlite3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.4/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/5.4/proxy-sqlite3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.4/proxy-sqlite3/requirements.txt +++ b/linux/advanced/zabbix/5.4/proxy-sqlite3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.4/server-mysql/Makefile b/linux/advanced/zabbix/5.4/server-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.4/server-mysql/Makefile +++ b/linux/advanced/zabbix/5.4/server-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.4/server-mysql/kaniko-build.py b/linux/advanced/zabbix/5.4/server-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.4/server-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.4/server-mysql/requirements.txt b/linux/advanced/zabbix/5.4/server-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.4/server-mysql/requirements.txt +++ b/linux/advanced/zabbix/5.4/server-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.4/server-pgsql/Makefile b/linux/advanced/zabbix/5.4/server-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.4/server-pgsql/Makefile +++ b/linux/advanced/zabbix/5.4/server-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.4/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/5.4/server-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.4/server-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.4/server-pgsql/requirements.txt b/linux/advanced/zabbix/5.4/server-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.4/server-pgsql/requirements.txt +++ b/linux/advanced/zabbix/5.4/server-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.4/snmptraps/Makefile b/linux/advanced/zabbix/5.4/snmptraps/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.4/snmptraps/Makefile +++ b/linux/advanced/zabbix/5.4/snmptraps/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.4/snmptraps/kaniko-build.py b/linux/advanced/zabbix/5.4/snmptraps/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.4/snmptraps/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.4/snmptraps/requirements.txt b/linux/advanced/zabbix/5.4/snmptraps/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.4/snmptraps/requirements.txt +++ b/linux/advanced/zabbix/5.4/snmptraps/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.4/web-mysql/Makefile b/linux/advanced/zabbix/5.4/web-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.4/web-mysql/Makefile +++ b/linux/advanced/zabbix/5.4/web-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.4/web-mysql/kaniko-build.py b/linux/advanced/zabbix/5.4/web-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.4/web-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.4/web-mysql/requirements.txt b/linux/advanced/zabbix/5.4/web-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.4/web-mysql/requirements.txt +++ b/linux/advanced/zabbix/5.4/web-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/5.4/web-pgsql/Makefile b/linux/advanced/zabbix/5.4/web-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/5.4/web-pgsql/Makefile +++ b/linux/advanced/zabbix/5.4/web-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/5.4/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/5.4/web-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/5.4/web-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/5.4/web-pgsql/requirements.txt b/linux/advanced/zabbix/5.4/web-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/5.4/web-pgsql/requirements.txt +++ b/linux/advanced/zabbix/5.4/web-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.0/agent/Makefile b/linux/advanced/zabbix/6.0/agent/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.0/agent/Makefile +++ b/linux/advanced/zabbix/6.0/agent/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.0/agent/kaniko-build.py b/linux/advanced/zabbix/6.0/agent/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.0/agent/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.0/agent/requirements.txt b/linux/advanced/zabbix/6.0/agent/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.0/agent/requirements.txt +++ b/linux/advanced/zabbix/6.0/agent/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.0/agent2/Makefile b/linux/advanced/zabbix/6.0/agent2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.0/agent2/Makefile +++ b/linux/advanced/zabbix/6.0/agent2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.0/agent2/kaniko-build.py b/linux/advanced/zabbix/6.0/agent2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.0/agent2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.0/agent2/requirements.txt b/linux/advanced/zabbix/6.0/agent2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.0/agent2/requirements.txt +++ b/linux/advanced/zabbix/6.0/agent2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.0/java-gateway/Makefile b/linux/advanced/zabbix/6.0/java-gateway/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.0/java-gateway/Makefile +++ b/linux/advanced/zabbix/6.0/java-gateway/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.0/java-gateway/kaniko-build.py b/linux/advanced/zabbix/6.0/java-gateway/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.0/java-gateway/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.0/java-gateway/requirements.txt b/linux/advanced/zabbix/6.0/java-gateway/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.0/java-gateway/requirements.txt +++ b/linux/advanced/zabbix/6.0/java-gateway/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.0/proxy-mysql/Makefile b/linux/advanced/zabbix/6.0/proxy-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.0/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/6.0/proxy-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.0/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/6.0/proxy-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.0/proxy-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.0/proxy-mysql/requirements.txt b/linux/advanced/zabbix/6.0/proxy-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.0/proxy-mysql/requirements.txt +++ b/linux/advanced/zabbix/6.0/proxy-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.0/proxy-sqlite3/Makefile b/linux/advanced/zabbix/6.0/proxy-sqlite3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.0/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/6.0/proxy-sqlite3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.0/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/6.0/proxy-sqlite3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.0/proxy-sqlite3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.0/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/6.0/proxy-sqlite3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.0/proxy-sqlite3/requirements.txt +++ b/linux/advanced/zabbix/6.0/proxy-sqlite3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.0/server-mysql/Makefile b/linux/advanced/zabbix/6.0/server-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.0/server-mysql/Makefile +++ b/linux/advanced/zabbix/6.0/server-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.0/server-mysql/kaniko-build.py b/linux/advanced/zabbix/6.0/server-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.0/server-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.0/server-mysql/requirements.txt b/linux/advanced/zabbix/6.0/server-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.0/server-mysql/requirements.txt +++ b/linux/advanced/zabbix/6.0/server-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.0/server-pgsql/Makefile b/linux/advanced/zabbix/6.0/server-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.0/server-pgsql/Makefile +++ b/linux/advanced/zabbix/6.0/server-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.0/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/6.0/server-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.0/server-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.0/server-pgsql/requirements.txt b/linux/advanced/zabbix/6.0/server-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.0/server-pgsql/requirements.txt +++ b/linux/advanced/zabbix/6.0/server-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.0/snmptraps/Makefile b/linux/advanced/zabbix/6.0/snmptraps/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.0/snmptraps/Makefile +++ b/linux/advanced/zabbix/6.0/snmptraps/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.0/snmptraps/kaniko-build.py b/linux/advanced/zabbix/6.0/snmptraps/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.0/snmptraps/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.0/snmptraps/requirements.txt b/linux/advanced/zabbix/6.0/snmptraps/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.0/snmptraps/requirements.txt +++ b/linux/advanced/zabbix/6.0/snmptraps/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.0/web-mysql/Makefile b/linux/advanced/zabbix/6.0/web-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.0/web-mysql/Makefile +++ b/linux/advanced/zabbix/6.0/web-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.0/web-mysql/kaniko-build.py b/linux/advanced/zabbix/6.0/web-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.0/web-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.0/web-mysql/requirements.txt b/linux/advanced/zabbix/6.0/web-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.0/web-mysql/requirements.txt +++ b/linux/advanced/zabbix/6.0/web-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.0/web-pgsql/Makefile b/linux/advanced/zabbix/6.0/web-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.0/web-pgsql/Makefile +++ b/linux/advanced/zabbix/6.0/web-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.0/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/6.0/web-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.0/web-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.0/web-pgsql/requirements.txt b/linux/advanced/zabbix/6.0/web-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.0/web-pgsql/requirements.txt +++ b/linux/advanced/zabbix/6.0/web-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.2/agent/Makefile b/linux/advanced/zabbix/6.2/agent/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.2/agent/Makefile +++ b/linux/advanced/zabbix/6.2/agent/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.2/agent/kaniko-build.py b/linux/advanced/zabbix/6.2/agent/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.2/agent/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.2/agent/requirements.txt b/linux/advanced/zabbix/6.2/agent/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.2/agent/requirements.txt +++ b/linux/advanced/zabbix/6.2/agent/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.2/agent2/Makefile b/linux/advanced/zabbix/6.2/agent2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.2/agent2/Makefile +++ b/linux/advanced/zabbix/6.2/agent2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.2/agent2/kaniko-build.py b/linux/advanced/zabbix/6.2/agent2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.2/agent2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.2/agent2/requirements.txt b/linux/advanced/zabbix/6.2/agent2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.2/agent2/requirements.txt +++ b/linux/advanced/zabbix/6.2/agent2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.2/java-gateway/Makefile b/linux/advanced/zabbix/6.2/java-gateway/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.2/java-gateway/Makefile +++ b/linux/advanced/zabbix/6.2/java-gateway/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.2/java-gateway/kaniko-build.py b/linux/advanced/zabbix/6.2/java-gateway/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.2/java-gateway/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.2/java-gateway/requirements.txt b/linux/advanced/zabbix/6.2/java-gateway/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.2/java-gateway/requirements.txt +++ b/linux/advanced/zabbix/6.2/java-gateway/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.2/proxy-mysql/Makefile b/linux/advanced/zabbix/6.2/proxy-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.2/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/6.2/proxy-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.2/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/6.2/proxy-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.2/proxy-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.2/proxy-mysql/requirements.txt b/linux/advanced/zabbix/6.2/proxy-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.2/proxy-mysql/requirements.txt +++ b/linux/advanced/zabbix/6.2/proxy-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.2/proxy-sqlite3/Makefile b/linux/advanced/zabbix/6.2/proxy-sqlite3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.2/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/6.2/proxy-sqlite3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.2/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/6.2/proxy-sqlite3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.2/proxy-sqlite3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.2/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/6.2/proxy-sqlite3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.2/proxy-sqlite3/requirements.txt +++ b/linux/advanced/zabbix/6.2/proxy-sqlite3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.2/server-mysql/Makefile b/linux/advanced/zabbix/6.2/server-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.2/server-mysql/Makefile +++ b/linux/advanced/zabbix/6.2/server-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.2/server-mysql/kaniko-build.py b/linux/advanced/zabbix/6.2/server-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.2/server-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.2/server-mysql/requirements.txt b/linux/advanced/zabbix/6.2/server-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.2/server-mysql/requirements.txt +++ b/linux/advanced/zabbix/6.2/server-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.2/server-pgsql/Makefile b/linux/advanced/zabbix/6.2/server-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.2/server-pgsql/Makefile +++ b/linux/advanced/zabbix/6.2/server-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.2/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/6.2/server-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.2/server-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.2/server-pgsql/requirements.txt b/linux/advanced/zabbix/6.2/server-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.2/server-pgsql/requirements.txt +++ b/linux/advanced/zabbix/6.2/server-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.2/snmptraps/Makefile b/linux/advanced/zabbix/6.2/snmptraps/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.2/snmptraps/Makefile +++ b/linux/advanced/zabbix/6.2/snmptraps/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.2/snmptraps/kaniko-build.py b/linux/advanced/zabbix/6.2/snmptraps/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.2/snmptraps/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.2/snmptraps/requirements.txt b/linux/advanced/zabbix/6.2/snmptraps/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.2/snmptraps/requirements.txt +++ b/linux/advanced/zabbix/6.2/snmptraps/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.2/web-mysql/Makefile b/linux/advanced/zabbix/6.2/web-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.2/web-mysql/Makefile +++ b/linux/advanced/zabbix/6.2/web-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.2/web-mysql/kaniko-build.py b/linux/advanced/zabbix/6.2/web-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.2/web-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.2/web-mysql/requirements.txt b/linux/advanced/zabbix/6.2/web-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.2/web-mysql/requirements.txt +++ b/linux/advanced/zabbix/6.2/web-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.2/web-pgsql/Makefile b/linux/advanced/zabbix/6.2/web-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.2/web-pgsql/Makefile +++ b/linux/advanced/zabbix/6.2/web-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.2/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/6.2/web-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.2/web-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.2/web-pgsql/requirements.txt b/linux/advanced/zabbix/6.2/web-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.2/web-pgsql/requirements.txt +++ b/linux/advanced/zabbix/6.2/web-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.4/agent/Makefile b/linux/advanced/zabbix/6.4/agent/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.4/agent/Makefile +++ b/linux/advanced/zabbix/6.4/agent/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.4/agent/kaniko-build.py b/linux/advanced/zabbix/6.4/agent/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.4/agent/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.4/agent/requirements.txt b/linux/advanced/zabbix/6.4/agent/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.4/agent/requirements.txt +++ b/linux/advanced/zabbix/6.4/agent/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.4/agent2/Makefile b/linux/advanced/zabbix/6.4/agent2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.4/agent2/Makefile +++ b/linux/advanced/zabbix/6.4/agent2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.4/agent2/kaniko-build.py b/linux/advanced/zabbix/6.4/agent2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.4/agent2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.4/agent2/requirements.txt b/linux/advanced/zabbix/6.4/agent2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.4/agent2/requirements.txt +++ b/linux/advanced/zabbix/6.4/agent2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.4/java-gateway/Makefile b/linux/advanced/zabbix/6.4/java-gateway/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.4/java-gateway/Makefile +++ b/linux/advanced/zabbix/6.4/java-gateway/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.4/java-gateway/kaniko-build.py b/linux/advanced/zabbix/6.4/java-gateway/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.4/java-gateway/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.4/java-gateway/requirements.txt b/linux/advanced/zabbix/6.4/java-gateway/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.4/java-gateway/requirements.txt +++ b/linux/advanced/zabbix/6.4/java-gateway/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.4/proxy-mysql/Makefile b/linux/advanced/zabbix/6.4/proxy-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.4/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/6.4/proxy-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.4/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/6.4/proxy-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.4/proxy-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.4/proxy-mysql/requirements.txt b/linux/advanced/zabbix/6.4/proxy-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.4/proxy-mysql/requirements.txt +++ b/linux/advanced/zabbix/6.4/proxy-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.4/proxy-sqlite3/Makefile b/linux/advanced/zabbix/6.4/proxy-sqlite3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.4/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/6.4/proxy-sqlite3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.4/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/6.4/proxy-sqlite3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.4/proxy-sqlite3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.4/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/6.4/proxy-sqlite3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.4/proxy-sqlite3/requirements.txt +++ b/linux/advanced/zabbix/6.4/proxy-sqlite3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.4/server-mysql/Makefile b/linux/advanced/zabbix/6.4/server-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.4/server-mysql/Makefile +++ b/linux/advanced/zabbix/6.4/server-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.4/server-mysql/kaniko-build.py b/linux/advanced/zabbix/6.4/server-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.4/server-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.4/server-mysql/requirements.txt b/linux/advanced/zabbix/6.4/server-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.4/server-mysql/requirements.txt +++ b/linux/advanced/zabbix/6.4/server-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.4/server-pgsql/Makefile b/linux/advanced/zabbix/6.4/server-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.4/server-pgsql/Makefile +++ b/linux/advanced/zabbix/6.4/server-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.4/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/6.4/server-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.4/server-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.4/server-pgsql/requirements.txt b/linux/advanced/zabbix/6.4/server-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.4/server-pgsql/requirements.txt +++ b/linux/advanced/zabbix/6.4/server-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.4/snmptraps/Makefile b/linux/advanced/zabbix/6.4/snmptraps/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.4/snmptraps/Makefile +++ b/linux/advanced/zabbix/6.4/snmptraps/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.4/snmptraps/kaniko-build.py b/linux/advanced/zabbix/6.4/snmptraps/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.4/snmptraps/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.4/snmptraps/requirements.txt b/linux/advanced/zabbix/6.4/snmptraps/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.4/snmptraps/requirements.txt +++ b/linux/advanced/zabbix/6.4/snmptraps/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.4/web-mysql/Makefile b/linux/advanced/zabbix/6.4/web-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.4/web-mysql/Makefile +++ b/linux/advanced/zabbix/6.4/web-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.4/web-mysql/kaniko-build.py b/linux/advanced/zabbix/6.4/web-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.4/web-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.4/web-mysql/requirements.txt b/linux/advanced/zabbix/6.4/web-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.4/web-mysql/requirements.txt +++ b/linux/advanced/zabbix/6.4/web-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/6.4/web-pgsql/Makefile b/linux/advanced/zabbix/6.4/web-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/6.4/web-pgsql/Makefile +++ b/linux/advanced/zabbix/6.4/web-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/6.4/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/6.4/web-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/6.4/web-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/6.4/web-pgsql/requirements.txt b/linux/advanced/zabbix/6.4/web-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/6.4/web-pgsql/requirements.txt +++ b/linux/advanced/zabbix/6.4/web-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/latest/agent/Makefile b/linux/advanced/zabbix/latest/agent/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/latest/agent/Makefile +++ b/linux/advanced/zabbix/latest/agent/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/latest/agent/kaniko-build.py b/linux/advanced/zabbix/latest/agent/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/latest/agent/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/latest/agent/requirements.txt b/linux/advanced/zabbix/latest/agent/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/latest/agent/requirements.txt +++ b/linux/advanced/zabbix/latest/agent/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/latest/agent2/Makefile b/linux/advanced/zabbix/latest/agent2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/latest/agent2/Makefile +++ b/linux/advanced/zabbix/latest/agent2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/latest/agent2/kaniko-build.py b/linux/advanced/zabbix/latest/agent2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/latest/agent2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/latest/agent2/requirements.txt b/linux/advanced/zabbix/latest/agent2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/latest/agent2/requirements.txt +++ b/linux/advanced/zabbix/latest/agent2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/latest/java-gateway/Makefile b/linux/advanced/zabbix/latest/java-gateway/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/latest/java-gateway/Makefile +++ b/linux/advanced/zabbix/latest/java-gateway/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/latest/java-gateway/kaniko-build.py b/linux/advanced/zabbix/latest/java-gateway/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/latest/java-gateway/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/latest/java-gateway/requirements.txt b/linux/advanced/zabbix/latest/java-gateway/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/latest/java-gateway/requirements.txt +++ b/linux/advanced/zabbix/latest/java-gateway/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/latest/proxy-mysql/Makefile b/linux/advanced/zabbix/latest/proxy-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/latest/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/latest/proxy-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/latest/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/latest/proxy-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/latest/proxy-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/latest/proxy-mysql/requirements.txt b/linux/advanced/zabbix/latest/proxy-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/latest/proxy-mysql/requirements.txt +++ b/linux/advanced/zabbix/latest/proxy-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/latest/proxy-sqlite3/Makefile b/linux/advanced/zabbix/latest/proxy-sqlite3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/latest/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/latest/proxy-sqlite3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/latest/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/latest/proxy-sqlite3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/latest/proxy-sqlite3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/latest/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/latest/proxy-sqlite3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/latest/proxy-sqlite3/requirements.txt +++ b/linux/advanced/zabbix/latest/proxy-sqlite3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/latest/server-mysql/Makefile b/linux/advanced/zabbix/latest/server-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/latest/server-mysql/Makefile +++ b/linux/advanced/zabbix/latest/server-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/latest/server-mysql/kaniko-build.py b/linux/advanced/zabbix/latest/server-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/latest/server-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/latest/server-mysql/requirements.txt b/linux/advanced/zabbix/latest/server-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/latest/server-mysql/requirements.txt +++ b/linux/advanced/zabbix/latest/server-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/latest/server-pgsql/Makefile b/linux/advanced/zabbix/latest/server-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/latest/server-pgsql/Makefile +++ b/linux/advanced/zabbix/latest/server-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/latest/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/latest/server-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/latest/server-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/latest/server-pgsql/requirements.txt b/linux/advanced/zabbix/latest/server-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/latest/server-pgsql/requirements.txt +++ b/linux/advanced/zabbix/latest/server-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/latest/snmptraps/Makefile b/linux/advanced/zabbix/latest/snmptraps/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/latest/snmptraps/Makefile +++ b/linux/advanced/zabbix/latest/snmptraps/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/latest/snmptraps/kaniko-build.py b/linux/advanced/zabbix/latest/snmptraps/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/latest/snmptraps/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/latest/snmptraps/requirements.txt b/linux/advanced/zabbix/latest/snmptraps/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/latest/snmptraps/requirements.txt +++ b/linux/advanced/zabbix/latest/snmptraps/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/latest/web-mysql/Makefile b/linux/advanced/zabbix/latest/web-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/latest/web-mysql/Makefile +++ b/linux/advanced/zabbix/latest/web-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/latest/web-mysql/kaniko-build.py b/linux/advanced/zabbix/latest/web-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/latest/web-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/latest/web-mysql/requirements.txt b/linux/advanced/zabbix/latest/web-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/latest/web-mysql/requirements.txt +++ b/linux/advanced/zabbix/latest/web-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/latest/web-pgsql/Makefile b/linux/advanced/zabbix/latest/web-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/latest/web-pgsql/Makefile +++ b/linux/advanced/zabbix/latest/web-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/latest/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/latest/web-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/latest/web-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/latest/web-pgsql/requirements.txt b/linux/advanced/zabbix/latest/web-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/latest/web-pgsql/requirements.txt +++ b/linux/advanced/zabbix/latest/web-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/trunk/agent/Makefile b/linux/advanced/zabbix/trunk/agent/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/trunk/agent/Makefile +++ b/linux/advanced/zabbix/trunk/agent/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/trunk/agent/kaniko-build.py b/linux/advanced/zabbix/trunk/agent/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/trunk/agent/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/trunk/agent/requirements.txt b/linux/advanced/zabbix/trunk/agent/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/trunk/agent/requirements.txt +++ b/linux/advanced/zabbix/trunk/agent/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/trunk/agent2/Makefile b/linux/advanced/zabbix/trunk/agent2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/trunk/agent2/Makefile +++ b/linux/advanced/zabbix/trunk/agent2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/trunk/agent2/kaniko-build.py b/linux/advanced/zabbix/trunk/agent2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/trunk/agent2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/trunk/agent2/requirements.txt b/linux/advanced/zabbix/trunk/agent2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/trunk/agent2/requirements.txt +++ b/linux/advanced/zabbix/trunk/agent2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/trunk/java-gateway/Makefile b/linux/advanced/zabbix/trunk/java-gateway/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/trunk/java-gateway/Makefile +++ b/linux/advanced/zabbix/trunk/java-gateway/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/trunk/java-gateway/kaniko-build.py b/linux/advanced/zabbix/trunk/java-gateway/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/trunk/java-gateway/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/trunk/java-gateway/requirements.txt b/linux/advanced/zabbix/trunk/java-gateway/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/trunk/java-gateway/requirements.txt +++ b/linux/advanced/zabbix/trunk/java-gateway/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/trunk/proxy-mysql/Makefile b/linux/advanced/zabbix/trunk/proxy-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/trunk/proxy-mysql/Makefile +++ b/linux/advanced/zabbix/trunk/proxy-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/trunk/proxy-mysql/kaniko-build.py b/linux/advanced/zabbix/trunk/proxy-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/trunk/proxy-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/trunk/proxy-mysql/requirements.txt b/linux/advanced/zabbix/trunk/proxy-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/trunk/proxy-mysql/requirements.txt +++ b/linux/advanced/zabbix/trunk/proxy-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/trunk/proxy-sqlite3/Makefile b/linux/advanced/zabbix/trunk/proxy-sqlite3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/trunk/proxy-sqlite3/Makefile +++ b/linux/advanced/zabbix/trunk/proxy-sqlite3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/trunk/proxy-sqlite3/kaniko-build.py b/linux/advanced/zabbix/trunk/proxy-sqlite3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/trunk/proxy-sqlite3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/trunk/proxy-sqlite3/requirements.txt b/linux/advanced/zabbix/trunk/proxy-sqlite3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/trunk/proxy-sqlite3/requirements.txt +++ b/linux/advanced/zabbix/trunk/proxy-sqlite3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/trunk/server-mysql/Makefile b/linux/advanced/zabbix/trunk/server-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/trunk/server-mysql/Makefile +++ b/linux/advanced/zabbix/trunk/server-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/trunk/server-mysql/kaniko-build.py b/linux/advanced/zabbix/trunk/server-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/trunk/server-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/trunk/server-mysql/requirements.txt b/linux/advanced/zabbix/trunk/server-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/trunk/server-mysql/requirements.txt +++ b/linux/advanced/zabbix/trunk/server-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/trunk/server-pgsql/Makefile b/linux/advanced/zabbix/trunk/server-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/trunk/server-pgsql/Makefile +++ b/linux/advanced/zabbix/trunk/server-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/trunk/server-pgsql/kaniko-build.py b/linux/advanced/zabbix/trunk/server-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/trunk/server-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/trunk/server-pgsql/requirements.txt b/linux/advanced/zabbix/trunk/server-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/trunk/server-pgsql/requirements.txt +++ b/linux/advanced/zabbix/trunk/server-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/trunk/snmptraps/Makefile b/linux/advanced/zabbix/trunk/snmptraps/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/trunk/snmptraps/Makefile +++ b/linux/advanced/zabbix/trunk/snmptraps/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/trunk/snmptraps/kaniko-build.py b/linux/advanced/zabbix/trunk/snmptraps/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/trunk/snmptraps/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/trunk/snmptraps/requirements.txt b/linux/advanced/zabbix/trunk/snmptraps/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/trunk/snmptraps/requirements.txt +++ b/linux/advanced/zabbix/trunk/snmptraps/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/trunk/web-mysql/Makefile b/linux/advanced/zabbix/trunk/web-mysql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/trunk/web-mysql/Makefile +++ b/linux/advanced/zabbix/trunk/web-mysql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/trunk/web-mysql/kaniko-build.py b/linux/advanced/zabbix/trunk/web-mysql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/trunk/web-mysql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/trunk/web-mysql/requirements.txt b/linux/advanced/zabbix/trunk/web-mysql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/trunk/web-mysql/requirements.txt +++ b/linux/advanced/zabbix/trunk/web-mysql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/advanced/zabbix/trunk/web-pgsql/Makefile b/linux/advanced/zabbix/trunk/web-pgsql/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/advanced/zabbix/trunk/web-pgsql/Makefile +++ b/linux/advanced/zabbix/trunk/web-pgsql/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/advanced/zabbix/trunk/web-pgsql/kaniko-build.py b/linux/advanced/zabbix/trunk/web-pgsql/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/advanced/zabbix/trunk/web-pgsql/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/advanced/zabbix/trunk/web-pgsql/requirements.txt b/linux/advanced/zabbix/trunk/web-pgsql/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/advanced/zabbix/trunk/web-pgsql/requirements.txt +++ b/linux/advanced/zabbix/trunk/web-pgsql/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk11/Makefile b/linux/discontinued/ecosystem/epicmorg/devel/jdk11/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk11/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk11/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/devel/jdk11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk11/requirements.txt b/linux/discontinued/ecosystem/epicmorg/devel/jdk11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk11/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk16/Makefile b/linux/discontinued/ecosystem/epicmorg/devel/jdk16/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk16/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk16/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/devel/jdk16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk16/requirements.txt b/linux/discontinued/ecosystem/epicmorg/devel/jdk16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk16/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk6/Makefile b/linux/discontinued/ecosystem/epicmorg/devel/jdk6/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk6/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk6/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/devel/jdk6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk6/requirements.txt b/linux/discontinued/ecosystem/epicmorg/devel/jdk6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk6/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk7/Makefile b/linux/discontinued/ecosystem/epicmorg/devel/jdk7/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk7/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk7/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/devel/jdk7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk7/requirements.txt b/linux/discontinued/ecosystem/epicmorg/devel/jdk7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk7/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk8/Makefile b/linux/discontinued/ecosystem/epicmorg/devel/jdk8/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk8/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk8/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/devel/jdk8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/devel/jdk8/requirements.txt b/linux/discontinued/ecosystem/epicmorg/devel/jdk8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/jdk8/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/devel/jdk8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/devel/main/Makefile b/linux/discontinued/ecosystem/epicmorg/devel/main/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/main/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/devel/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/devel/main/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/devel/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/devel/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/devel/main/requirements.txt b/linux/discontinued/ecosystem/epicmorg/devel/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/devel/main/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/devel/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk11/Makefile b/linux/discontinued/ecosystem/epicmorg/edge/jdk11/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk11/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk11/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/edge/jdk11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk11/requirements.txt b/linux/discontinued/ecosystem/epicmorg/edge/jdk11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk11/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk16/Makefile b/linux/discontinued/ecosystem/epicmorg/edge/jdk16/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk16/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk16/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/edge/jdk16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk16/requirements.txt b/linux/discontinued/ecosystem/epicmorg/edge/jdk16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk16/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk6/Makefile b/linux/discontinued/ecosystem/epicmorg/edge/jdk6/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk6/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk6/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/edge/jdk6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk6/requirements.txt b/linux/discontinued/ecosystem/epicmorg/edge/jdk6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk6/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk7/Makefile b/linux/discontinued/ecosystem/epicmorg/edge/jdk7/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk7/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk7/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/edge/jdk7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk7/requirements.txt b/linux/discontinued/ecosystem/epicmorg/edge/jdk7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk7/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk8/Makefile b/linux/discontinued/ecosystem/epicmorg/edge/jdk8/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk8/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk8/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/edge/jdk8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/edge/jdk8/requirements.txt b/linux/discontinued/ecosystem/epicmorg/edge/jdk8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/jdk8/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/edge/jdk8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/edge/main/Makefile b/linux/discontinued/ecosystem/epicmorg/edge/main/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/main/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/edge/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/edge/main/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/edge/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/edge/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/edge/main/requirements.txt b/linux/discontinued/ecosystem/epicmorg/edge/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/edge/main/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/edge/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk11/Makefile b/linux/discontinued/ecosystem/epicmorg/prod/jdk11/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk11/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk11/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/prod/jdk11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk11/requirements.txt b/linux/discontinued/ecosystem/epicmorg/prod/jdk11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk11/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk16/Makefile b/linux/discontinued/ecosystem/epicmorg/prod/jdk16/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk16/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk16/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/prod/jdk16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk16/requirements.txt b/linux/discontinued/ecosystem/epicmorg/prod/jdk16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk16/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk6/Makefile b/linux/discontinued/ecosystem/epicmorg/prod/jdk6/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk6/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk6/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/prod/jdk6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk6/requirements.txt b/linux/discontinued/ecosystem/epicmorg/prod/jdk6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk6/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk7/Makefile b/linux/discontinued/ecosystem/epicmorg/prod/jdk7/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk7/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk7/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/prod/jdk7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk7/requirements.txt b/linux/discontinued/ecosystem/epicmorg/prod/jdk7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk7/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk8/Makefile b/linux/discontinued/ecosystem/epicmorg/prod/jdk8/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk8/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk8/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/prod/jdk8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/prod/jdk8/requirements.txt b/linux/discontinued/ecosystem/epicmorg/prod/jdk8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/jdk8/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/prod/jdk8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/epicmorg/prod/main/Makefile b/linux/discontinued/ecosystem/epicmorg/prod/main/Makefile index 3675f4fa8..0adfe5b54 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/main/Makefile +++ b/linux/discontinued/ecosystem/epicmorg/prod/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/epicmorg/prod/main/kaniko-build.py b/linux/discontinued/ecosystem/epicmorg/prod/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/epicmorg/prod/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/epicmorg/prod/main/requirements.txt b/linux/discontinued/ecosystem/epicmorg/prod/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/epicmorg/prod/main/requirements.txt +++ b/linux/discontinued/ecosystem/epicmorg/prod/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.0/Makefile b/linux/discontinued/ecosystem/freegpt-webui/1.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.0/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/1.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.0/kaniko-build.py b/linux/discontinued/ecosystem/freegpt-webui/1.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/freegpt-webui/1.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.0/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/1.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.0/requirements.txt +++ b/linux/discontinued/ecosystem/freegpt-webui/1.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.1/Makefile b/linux/discontinued/ecosystem/freegpt-webui/1.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.1/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/1.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.1/kaniko-build.py b/linux/discontinued/ecosystem/freegpt-webui/1.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/freegpt-webui/1.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.1/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/1.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.1/requirements.txt +++ b/linux/discontinued/ecosystem/freegpt-webui/1.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.2/Makefile b/linux/discontinued/ecosystem/freegpt-webui/1.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.2/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/1.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.2/kaniko-build.py b/linux/discontinued/ecosystem/freegpt-webui/1.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/freegpt-webui/1.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.2/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/1.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.2/requirements.txt +++ b/linux/discontinued/ecosystem/freegpt-webui/1.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.3.1/Makefile b/linux/discontinued/ecosystem/freegpt-webui/1.3.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.3.1/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/1.3.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.3.1/kaniko-build.py b/linux/discontinued/ecosystem/freegpt-webui/1.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/freegpt-webui/1.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.3.1/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/1.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.3.1/requirements.txt +++ b/linux/discontinued/ecosystem/freegpt-webui/1.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.3.2/Makefile b/linux/discontinued/ecosystem/freegpt-webui/1.3.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.3.2/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/1.3.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.3.2/kaniko-build.py b/linux/discontinued/ecosystem/freegpt-webui/1.3.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/freegpt-webui/1.3.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.3.2/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/1.3.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.3.2/requirements.txt +++ b/linux/discontinued/ecosystem/freegpt-webui/1.3.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.3/Makefile b/linux/discontinued/ecosystem/freegpt-webui/1.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.3/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/1.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.3/kaniko-build.py b/linux/discontinued/ecosystem/freegpt-webui/1.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/freegpt-webui/1.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.3/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/1.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.3/requirements.txt +++ b/linux/discontinued/ecosystem/freegpt-webui/1.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.4/Makefile b/linux/discontinued/ecosystem/freegpt-webui/1.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.4/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/1.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.4/kaniko-build.py b/linux/discontinued/ecosystem/freegpt-webui/1.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/freegpt-webui/1.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/freegpt-webui/1.4/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/1.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/1.4/requirements.txt +++ b/linux/discontinued/ecosystem/freegpt-webui/1.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/freegpt-webui/latest/Makefile b/linux/discontinued/ecosystem/freegpt-webui/latest/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/latest/Makefile +++ b/linux/discontinued/ecosystem/freegpt-webui/latest/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/discontinued/ecosystem/freegpt-webui/latest/kaniko-build.py b/linux/discontinued/ecosystem/freegpt-webui/latest/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/freegpt-webui/latest/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/freegpt-webui/latest/requirements.txt b/linux/discontinued/ecosystem/freegpt-webui/latest/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/freegpt-webui/latest/requirements.txt +++ b/linux/discontinued/ecosystem/freegpt-webui/latest/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/discontinued/ecosystem/syspass/sysPass/kaniko-build.py b/linux/discontinued/ecosystem/syspass/sysPass/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/discontinued/ecosystem/syspass/sysPass/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/discontinued/ecosystem/syspass/sysPass/requirements.txt b/linux/discontinued/ecosystem/syspass/sysPass/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/discontinued/ecosystem/syspass/sysPass/requirements.txt +++ b/linux/discontinued/ecosystem/syspass/sysPass/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/apache2/php5.5/Makefile b/linux/ecosystem/apache2/php5.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/apache2/php5.5/Makefile +++ b/linux/ecosystem/apache2/php5.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/apache2/php5.5/kaniko-build.py b/linux/ecosystem/apache2/php5.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/apache2/php5.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/apache2/php5.5/requirements.txt b/linux/ecosystem/apache2/php5.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/apache2/php5.5/requirements.txt +++ b/linux/ecosystem/apache2/php5.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/apache2/php7.0/Makefile b/linux/ecosystem/apache2/php7.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/apache2/php7.0/Makefile +++ b/linux/ecosystem/apache2/php7.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/apache2/php7.0/kaniko-build.py b/linux/ecosystem/apache2/php7.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/apache2/php7.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/apache2/php7.0/requirements.txt b/linux/ecosystem/apache2/php7.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/apache2/php7.0/requirements.txt +++ b/linux/ecosystem/apache2/php7.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/apache2/php7.1/Makefile b/linux/ecosystem/apache2/php7.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/apache2/php7.1/Makefile +++ b/linux/ecosystem/apache2/php7.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/apache2/php7.1/kaniko-build.py b/linux/ecosystem/apache2/php7.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/apache2/php7.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/apache2/php7.1/requirements.txt b/linux/ecosystem/apache2/php7.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/apache2/php7.1/requirements.txt +++ b/linux/ecosystem/apache2/php7.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/apache2/php7.2/Makefile b/linux/ecosystem/apache2/php7.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/apache2/php7.2/Makefile +++ b/linux/ecosystem/apache2/php7.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/apache2/php7.2/kaniko-build.py b/linux/ecosystem/apache2/php7.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/apache2/php7.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/apache2/php7.2/requirements.txt b/linux/ecosystem/apache2/php7.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/apache2/php7.2/requirements.txt +++ b/linux/ecosystem/apache2/php7.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/apache2/php7.3/Makefile b/linux/ecosystem/apache2/php7.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/apache2/php7.3/Makefile +++ b/linux/ecosystem/apache2/php7.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/apache2/php7.3/kaniko-build.py b/linux/ecosystem/apache2/php7.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/apache2/php7.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/apache2/php7.3/requirements.txt b/linux/ecosystem/apache2/php7.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/apache2/php7.3/requirements.txt +++ b/linux/ecosystem/apache2/php7.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/apache2/php7.4/Makefile b/linux/ecosystem/apache2/php7.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/apache2/php7.4/Makefile +++ b/linux/ecosystem/apache2/php7.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/apache2/php7.4/kaniko-build.py b/linux/ecosystem/apache2/php7.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/apache2/php7.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/apache2/php7.4/requirements.txt b/linux/ecosystem/apache2/php7.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/apache2/php7.4/requirements.txt +++ b/linux/ecosystem/apache2/php7.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/apache2/php8.0/Makefile b/linux/ecosystem/apache2/php8.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/apache2/php8.0/Makefile +++ b/linux/ecosystem/apache2/php8.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/apache2/php8.0/kaniko-build.py b/linux/ecosystem/apache2/php8.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/apache2/php8.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/apache2/php8.0/requirements.txt b/linux/ecosystem/apache2/php8.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/apache2/php8.0/requirements.txt +++ b/linux/ecosystem/apache2/php8.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/apache2/php8.1/Makefile b/linux/ecosystem/apache2/php8.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/apache2/php8.1/Makefile +++ b/linux/ecosystem/apache2/php8.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/apache2/php8.1/kaniko-build.py b/linux/ecosystem/apache2/php8.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/apache2/php8.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/apache2/php8.1/requirements.txt b/linux/ecosystem/apache2/php8.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/apache2/php8.1/requirements.txt +++ b/linux/ecosystem/apache2/php8.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/apache2/php8.2/Makefile b/linux/ecosystem/apache2/php8.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/apache2/php8.2/Makefile +++ b/linux/ecosystem/apache2/php8.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/apache2/php8.2/kaniko-build.py b/linux/ecosystem/apache2/php8.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/apache2/php8.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/apache2/php8.2/requirements.txt b/linux/ecosystem/apache2/php8.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/apache2/php8.2/requirements.txt +++ b/linux/ecosystem/apache2/php8.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/apache2/php8.3/Makefile b/linux/ecosystem/apache2/php8.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/apache2/php8.3/Makefile +++ b/linux/ecosystem/apache2/php8.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/apache2/php8.3/kaniko-build.py b/linux/ecosystem/apache2/php8.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/apache2/php8.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/apache2/php8.3/requirements.txt b/linux/ecosystem/apache2/php8.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/apache2/php8.3/requirements.txt +++ b/linux/ecosystem/apache2/php8.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.0.3/Makefile b/linux/ecosystem/atlassian/bitbucket/1/1.0.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/1/1.0.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/1/1.0.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.0.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/1/1.0.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/1/1.0.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.0.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/1/1.0.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/1/1.0.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/1/1.0.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.1.2/Makefile b/linux/ecosystem/atlassian/bitbucket/1/1.1.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/1/1.1.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/1/1.1.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.1.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/1/1.1.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/1/1.1.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.1.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/1/1.1.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/1/1.1.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/1/1.1.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.2.1/Makefile b/linux/ecosystem/atlassian/bitbucket/1/1.2.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/1/1.2.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/1/1.2.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.2.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/1/1.2.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/1/1.2.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.2.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/1/1.2.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/1/1.2.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/1/1.2.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.2.4/Makefile b/linux/ecosystem/atlassian/bitbucket/1/1.2.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/1/1.2.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/1/1.2.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.2.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/1/1.2.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/1/1.2.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.2.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/1/1.2.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/1/1.2.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/1/1.2.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.3.1/Makefile b/linux/ecosystem/atlassian/bitbucket/1/1.3.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/1/1.3.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/1/1.3.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.3.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/1/1.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/1/1.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/1/1.3.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/1/1.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/1/1.3.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/1/1.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.0.3/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.0.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.0.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.0.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.0.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.0.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.0.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.0.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.0.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.0.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.0.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.1.2/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.1.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.1.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.1.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.1.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.1.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.1.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.1.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.1.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.1.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.1.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.0/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.10.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.10.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.10.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.1/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.10.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.10.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.10.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.2/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.10.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.10.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.10.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.3/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.10.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.10.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.10.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.4/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.10.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.10.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.10.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.5/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.10.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.5/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.10.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.10.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.10.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.10.5/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.10.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.3/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.11.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.11.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.11.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.4/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.11.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.11.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.11.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.5/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.11.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.5/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.11.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.11.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.5/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.6/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.11.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.6/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.11.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.11.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.6/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.7/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.11.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.7/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.7/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.11.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.7/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.11.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.7/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.8/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.11.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.8/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.8/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.11.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.8/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.11.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.8/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.9/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.11.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.9/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.9/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.11.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.11.9/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.11.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.11.9/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.11.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.0/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.12.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.12.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.12.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.1/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.12.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.12.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.12.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.2/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.12.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.12.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.12.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.3/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.12.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.12.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.12.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.4/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.12.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.12.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.12.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.5/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.12.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.5/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.12.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.12.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.5/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.6/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.12.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.6/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.12.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.12.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.12.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.12.6/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.12.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.2.0/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.2.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.2.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.2.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.2.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.2.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.2.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.2.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.2.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.2.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.2.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.3.1/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.3.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.3.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.3.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.3.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.3.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.3.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.4.2/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.4.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.4.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.4.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.4.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.4.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.4.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.4.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.4.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.4.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.4.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.5.4/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.5.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.5.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.5.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.5.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.5.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.5.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.5.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.5.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.5.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.5.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.6.5/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.6.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.6.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.6.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.6.5/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.6.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.6.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.6.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.6.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.6.5/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.6.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.7.6/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.7.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.7.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.7.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.7.6/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.7.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.7.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.7.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.7.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.7.6/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.7.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.8.4/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.8.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.8.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.8.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.8.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.8.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.8.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.8.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.8.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.8.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.8.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.8.5/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.8.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.8.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.8.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.8.5/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.8.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.8.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.8.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.8.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.8.5/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.8.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.1/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.9.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.9.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.9.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.2/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.9.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.9.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.9.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.3/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.9.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.9.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.9.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.4/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.9.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.9.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.9.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.5/Makefile b/linux/ecosystem/atlassian/bitbucket/2/2.9.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.5/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/2/2.9.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/2/2.9.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/2/2.9.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/2/2.9.5/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/2/2.9.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.0.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.0.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.0.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.4/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.0.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.0.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.0.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.5/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.0.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.5/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.0.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.0.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.5/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.6/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.0.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.6/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.0.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.0.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.6/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.7/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.0.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.7/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.7/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.0.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.7/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.0.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.7/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.8/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.0.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.8/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.8/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.0.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.0.8/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.0.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.0.8/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.0.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.1.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.1.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.1.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.1.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.1.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.1.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.3/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.1.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.1.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.1.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.4/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.1.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.1.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.1.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.5/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.1.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.5/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.1.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.1.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.5/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.7/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.1.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.7/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.7/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.1.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.1.7/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.1.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.1.7/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.1.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.10.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.10.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.10.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.2/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.10.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.10.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.10.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.3/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.10.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.10.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.10.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.4/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.10.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.10.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.10.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.10.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.10.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.10.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.11.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.11.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.11.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.11.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.11.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.11.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.2/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.11.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.11.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.11.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.3/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.11.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.11.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.11.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.4/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.11.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.11.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.11.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.6/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.11.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.6/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.11.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.11.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.11.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.11.6/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.11.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.2.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.2.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.2.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.2/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.2.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.2.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.2.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.4/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.2.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.2.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.2.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.5/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.2.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.5/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.2.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.2.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.5/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.7/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.2.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.7/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.7/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.2.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.2.7/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.2.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.2.7/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.2.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.3.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.3.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.3.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.3.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.2/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.3.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.3.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.3.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.3/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.3.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.3.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.3.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.5/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.3.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.5/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.3.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.3.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.3.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.3.5/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.3.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.4.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.4.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.4.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.4.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.4.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.4.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.3/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.4.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.4.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.4.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.5/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.4.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.5/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.4.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.4.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.4.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.4.5/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.4.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.5.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.5.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.5.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.5.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.5.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.5.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.5.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.5.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.5.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.5.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.5.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.5.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.5.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.5.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.5.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.5.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.5.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.5.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.5.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.5.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.5.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.5.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.6.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.6.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.6.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.6.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.6.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.6.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.6.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.6.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.6.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.6.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.6.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.6.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.6.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.6.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.6.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.6.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.6.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.6.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.6.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.6.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.6.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.6.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.7.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.7.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.7.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.7.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.7.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.7.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.2/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.7.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.7.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.7.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.3/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.7.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.7.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.7.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.4/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.7.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.7.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.7.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.7.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.7.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.7.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.8.0/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.8.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.8.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.8.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.8.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.8.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.8.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.8.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.8.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.8.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.8.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.8.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.8.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.8.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.8.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.8.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.8.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.8.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.8.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.8.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.8.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.8.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.9.1/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.9.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.9.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.9.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.9.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.9.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.9.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.9.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.9.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.9.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.9.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.9.2/Makefile b/linux/ecosystem/atlassian/bitbucket/3/3.9.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.9.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/3/3.9.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.9.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/3/3.9.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/3/3.9.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/3/3.9.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/3/3.9.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/3/3.9.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/3/3.9.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.0.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.0.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.0.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.0.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.0.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.0.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.0.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.0.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.0.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.4/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.0.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.0.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.0.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.6/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.0.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.6/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.0.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.0.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.6/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.7/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.0.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.7/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.7/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.0.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.7/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.0.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.7/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.8/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.0.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.8/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.8/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.0.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.0.8/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.0.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.0.8/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.0.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.1.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.1.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.1.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.1.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.1.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.1.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.4/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.1.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.1.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.1.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.6/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.1.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.6/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.1.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.1.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.1.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.1.6/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.1.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.10.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.10.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.10.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.10.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.10.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.10.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.10.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.10.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.10.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.10.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.10.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.10.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.10.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.10.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.10.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.10.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.10.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.10.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.10.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.10.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.10.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.10.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.10.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.10.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.10.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.10.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.10.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.10.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.10.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.10.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.10.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.10.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.10.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.11.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.11.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.11.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.11.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.11.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.11.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.11.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.11.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.11.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.11.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.11.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.11.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.11.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.11.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.11.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.11.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.11.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.11.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.11.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.11.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.11.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.11.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.12.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.12.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.12.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.12.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.12.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.12.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.12.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.12.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.12.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.12.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.12.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.12.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.12.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.12.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.12.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.12.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.12.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.12.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.12.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.12.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.12.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.12.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.13.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.13.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.13.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.13.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.13.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.13.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.13.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.13.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.13.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.13.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.13.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.13.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.13.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.13.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.13.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.13.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.13.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.13.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.13.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.13.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.13.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.13.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.14.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.14.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.10/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.10/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.10/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.14.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.10/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.10/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.11/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.11/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.11/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.14.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.11/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.11/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.12/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.12/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.12/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.14.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.12/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.12/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.14.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.14.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.4/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.14.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.5/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.5/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.14.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.5/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.6/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.6/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.14.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.6/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.7/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.7/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.7/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.14.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.7/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.7/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.8/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.8/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.8/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.14.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.8/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.8/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.9/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.14.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.9/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.9/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.14.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.14.9/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.14.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.14.9/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.14.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.2.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.2.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.2.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.2.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.2.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.2.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.2.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.2.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.2.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.2.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.2.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.2.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.2.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.2.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.2.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.3.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.3.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.3.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.3.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.3.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.3.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.3.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.3.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.3.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.3.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.3.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.3.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.3.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.4.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.4.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.4.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.4.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.4.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.4.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.4.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.4.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.4.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.4/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.4.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.4.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.4.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.4.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.4.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.4.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.5.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.5.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.5.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.5.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.5.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.5.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.5.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.5.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.5.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.5.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.5.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.5.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.5.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.5.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.5.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.5.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.5.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.5.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.5.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.5.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.5.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.5.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.5.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.5.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.5.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.5.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.5.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.5.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.5.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.5.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.5.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.5.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.5.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.6.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.6.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.6.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.6.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.6.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.6.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.6.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.6.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.6.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.6.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.6.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.6.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.4/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.6.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.6.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.6.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.6.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.6.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.6.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.7.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.7.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.7.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.7.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.7.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.7.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.7.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.7.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.7.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.7.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.7.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.7.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.7.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.7.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.7.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.7.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.7.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.7.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.7.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.7.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.7.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.7.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.8.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.8.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.8.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.8.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.8.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.8.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.2/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.8.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.8.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.8.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.3/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.8.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.8.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.8.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.4/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.8.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.8.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.8.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.5/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.8.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.5/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.5/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.8.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.5/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.8.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.5/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.6/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.8.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.6/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.8.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.8.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.8.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.8.6/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.8.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.9.0/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.9.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.9.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.9.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.9.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.9.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.9.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.9.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.9.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.9.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.9.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.9.1/Makefile b/linux/ecosystem/atlassian/bitbucket/4/4.9.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.9.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/4/4.9.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.9.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/4/4.9.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/4/4.9.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/4/4.9.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/4/4.9.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/4/4.9.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/4/4.9.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/7/7.21.4/Makefile b/linux/ecosystem/atlassian/bitbucket/7/7.21.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/7/7.21.4/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/7/7.21.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/7/7.21.4/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/7/7.21.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/7/7.21.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/7/7.21.4/requirements.txt b/linux/ecosystem/atlassian/bitbucket/7/7.21.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/7/7.21.4/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/7/7.21.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.0.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.0.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.0.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.0.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.0.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.0.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.0.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.0.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.0.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.0.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.0.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.0.3/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.0.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.0.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.0.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.0.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.0.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.0.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.0.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.0.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.0.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.0.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.1.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.1.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.1.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.1.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.1.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.1.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.1.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.1.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.1.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.1.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.1.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.1.3/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.1.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.1.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.1.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.1.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.1.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.1.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.1.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.1.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.1.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.1.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.12.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.12.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.12.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.12.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.12.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.12.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.12.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.12.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.12.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.12.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.12.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.17.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.17.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.17.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.17.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.17.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.17.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.17.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.17.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.17.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.17.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.17.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.19.6/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.19.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.19.6/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.19.6/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.19.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.2.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.2.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.2.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.2.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.2.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.2.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.2.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.2.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.2.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.2.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.2.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.2.2/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.2.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.2.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.2.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.2.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.2.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.2.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.2.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.2.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.2.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.2.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.3.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.3.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.3.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.1/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.3.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.2/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.3.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.3.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.3.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.3/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.3.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.3/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.3/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.3.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.3.3/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.3.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.3.3/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.3.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.4.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.4.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.4.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.4.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.4.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.4.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.4.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.4.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.4.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.4.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.4.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.4.1/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.4.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.4.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.4.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.4.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.4.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.4.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.4.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.4.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.4.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.4.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.4.2/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.4.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.4.2/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.4.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.4.2/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.4.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.4.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.4.2/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.4.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.4.2/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.4.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.5.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.5.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.5.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.5.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.5.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.5.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.5.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.5.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.5.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.5.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.5.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.5.1/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.5.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.5.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.5.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.5.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.5.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.5.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.5.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.5.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.5.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.5.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.6.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.6.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.6.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.6.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.6.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.6.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.6.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.6.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.6.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.6.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.6.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.6.1/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.6.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.6.1/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.6.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.6.1/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.6.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.6.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.6.1/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.6.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.6.1/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.6.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.7.0/Makefile b/linux/ecosystem/atlassian/bitbucket/8/8.7.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.7.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/8/8.7.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.7.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/8/8.7.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/8/8.7.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/8/8.7.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/8/8.7.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/8/8.7.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/8/8.7.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Makefile b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/9/9.0.0/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/9/9.0.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/9/9.0.0/requirements.txt b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/9/9.0.0/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/9/9.0.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/bitbucket/latest/Makefile b/linux/ecosystem/atlassian/bitbucket/latest/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/bitbucket/latest/Makefile +++ b/linux/ecosystem/atlassian/bitbucket/latest/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/bitbucket/latest/kaniko-build.py b/linux/ecosystem/atlassian/bitbucket/latest/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/bitbucket/latest/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/bitbucket/latest/requirements.txt b/linux/ecosystem/atlassian/bitbucket/latest/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/bitbucket/latest/requirements.txt +++ b/linux/ecosystem/atlassian/bitbucket/latest/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.0.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.0.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.0.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.0.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.0.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.0.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.0.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.0.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.0.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.0.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.0.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.0.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.0.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.0.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.0.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.0.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.0.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.0.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.0.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.0.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.0.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.0.4/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.0.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.0.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.0.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.0.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.0.4/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.0.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.0.5/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.0.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.0.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.0.5/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.0.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.0.5/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.0.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.0.6/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.0.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.0.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.0.6/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.0.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.0.6/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.0.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.0.7/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.0.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.0.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.0.7/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.0.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.0.7/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.0.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.1.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.1.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.1.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.1.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.1.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.1.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.1.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.1.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.1.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.1.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.1.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.1.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.1.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.1.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.1.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.1.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.1.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.1.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.1.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.1.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.1.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.1.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.1.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.1.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.1.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.1.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.1.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.1.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.1.4/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.1.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.1.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.1.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.1.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.1.4/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.1.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.10.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.10.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.10.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.10.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.10.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.10.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.10.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.10.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.10.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.10.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.10.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.10.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.10.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.10.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.10.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.10.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.10.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.10.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.10.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.10.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.10.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.10.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.10.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.10.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.10.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.10.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.10.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.10.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.11.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.11.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.11.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.11.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.11.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.11.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.11.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.11.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.11.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.11.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.11.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.11.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.11.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.11.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.11.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.11.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.11.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.11.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.11.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.11.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.11.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.12.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.12.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.12.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.12.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.12.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.12.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.12.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.12.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.12.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.12.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.12.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.12.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.12.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.12.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.12.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.12.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.12.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.12.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.12.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.12.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.12.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.12.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.12.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.12.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.12.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.12.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.12.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.12.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.12.4/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.12.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.12.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.12.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.12.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.12.4/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.12.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.10/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.10/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.10/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.11/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.11/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.11/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.12/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.12/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.12/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.13/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.13/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.13/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.15/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.15/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.15/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.17/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.17/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.17/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.18/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.18/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.18/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.19/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.19/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.19/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.20/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.20/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.20/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.21/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.21/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.21/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.4/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.4/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.5/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.5/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.5/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.6/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.6/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.6/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.7/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.7/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.7/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.8/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.8/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.8/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.9/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.13.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.13.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.13.9/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.13.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.13.9/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.13.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.14.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.14.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.14.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.14.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.14.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.14.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.14.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.14.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.14.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.14.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.14.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.14.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.14.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.14.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.14.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.14.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.14.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.14.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.14.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.14.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.14.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.14.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.14.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.14.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.14.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.14.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.14.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.14.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.15.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.15.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.15.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.15.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.10/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.15.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.15.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.10/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.15.10/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.15.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.15.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.15.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.15.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.15.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.4/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.15.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.15.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.15.4/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.15.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.6/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.15.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.15.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.6/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.15.6/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.15.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.7/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.15.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.15.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.7/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.15.7/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.15.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.8/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.15.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.15.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.8/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.15.8/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.15.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.9/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.15.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.15.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.15.9/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.15.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.15.9/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.15.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.2.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.2.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.2.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.2.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.2.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.2.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.2.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.2.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.2.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.2.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.2.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.2.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.2.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.2.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.2.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.2.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.2.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.2.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.2.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.2.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.2.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.2.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.2.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.2.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.2.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.2.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.2.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.2.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.2.4/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.2.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.2.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.2.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.2.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.2.4/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.2.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.3.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.3.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.3.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.3.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.3.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.3.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.3.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.3.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.3.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.3.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.3.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.3.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.3.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.3.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.3.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.3.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.3.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.3.4/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.3.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.3.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.3.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.3.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.3.4/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.3.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.4.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.4.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.4.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.4.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.4.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.4.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.4.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.4.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.4.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.4.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.4.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.4.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.4.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.4.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.4.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.4.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.4.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.4.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.4.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.4.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.4.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.4.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.4.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.4.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.4.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.4.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.4.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.4.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.5.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.5.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.5.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.5.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.5.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.5.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.5.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.5.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.5.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.5.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.5.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.5.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.5.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.5.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.5.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.5.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.5.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.5.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.5.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.5.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.5.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.5.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.5.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.5.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.5.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.5.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.5.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.5.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.10/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.10/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.10/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.11/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.11/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.11/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.12/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.12/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.12/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.13/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.13/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.13/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.14/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.14/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.14/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.15/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.15/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.15/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.16/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.16/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.16/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.17/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.17/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.17/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.4/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.4/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.4/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.5/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.5/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.5/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.6/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.6/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.6/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.7/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.7/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.7/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.8/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.8/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.8/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.9/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.6.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.6.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.6.9/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.6.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.6.9/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.6.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.7.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.7.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.7.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.7.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.7.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.7.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.7.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.7.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.7.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.7.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.7.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.7.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.7.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.7.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.7.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.7.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.7.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.7.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.7.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.7.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.7.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.7.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.7.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.7.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.7.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.7.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.7.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.7.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.8.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.8.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.8.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.8.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.8.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.8.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.8.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.8.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.8.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.8.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.8.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.8.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.8.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.8.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.8.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.8.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.8.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.8.2/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.8.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.8.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.8.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.8.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.8.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.8.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.8.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.8.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.8.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.8.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.8.5/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.8.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.8.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.8.5/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.8.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.8.5/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.8.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.9.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.9.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.9.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.9.0/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.9.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.9.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.9.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.9.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.9.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.9.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.9.1/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.9.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.9.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.9.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/6/6.9.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/6/6.9.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/6/6.9.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/6/6.9.3/requirements.txt b/linux/ecosystem/atlassian/confluence/6/6.9.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/6/6.9.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/6/6.9.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.0/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.0/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/7/7.19.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/7/7.19.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.0/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/7/7.19.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.1/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.1/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/7/7.19.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/7/7.19.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.1/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/7/7.19.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.16/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.16/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.16/kaniko-build.py b/linux/ecosystem/atlassian/confluence/7/7.19.16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/7/7.19.16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.16/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.16/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/7/7.19.16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.17/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.17/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.17/kaniko-build.py b/linux/ecosystem/atlassian/confluence/7/7.19.17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/7/7.19.17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.17/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.17/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/7/7.19.17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.18/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.18/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.18/kaniko-build.py b/linux/ecosystem/atlassian/confluence/7/7.19.18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/7/7.19.18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.18/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.18/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/7/7.19.18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.2/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.2/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/7/7.19.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/7/7.19.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.2/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/7/7.19.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.3/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.3/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/7/7.19.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/7/7.19.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.3/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/7/7.19.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.4/Makefile b/linux/ecosystem/atlassian/confluence/7/7.19.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.4/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.19.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.4/kaniko-build.py b/linux/ecosystem/atlassian/confluence/7/7.19.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/7/7.19.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/7/7.19.4/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.19.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.19.4/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/7/7.19.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.0/Makefile b/linux/ecosystem/atlassian/confluence/7/7.20.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.20.0/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.20.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/7/7.20.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/7/7.20.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.0/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.20.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.20.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/7/7.20.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.1/Makefile b/linux/ecosystem/atlassian/confluence/7/7.20.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.20.1/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.20.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/7/7.20.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/7/7.20.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.1/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.20.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.20.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/7/7.20.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.2/Makefile b/linux/ecosystem/atlassian/confluence/7/7.20.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.20.2/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.20.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/7/7.20.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/7/7.20.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.2/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.20.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.20.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/7/7.20.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.3/Makefile b/linux/ecosystem/atlassian/confluence/7/7.20.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.20.3/Makefile +++ b/linux/ecosystem/atlassian/confluence/7/7.20.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/7/7.20.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/7/7.20.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/7/7.20.3/requirements.txt b/linux/ecosystem/atlassian/confluence/7/7.20.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/7/7.20.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/7/7.20.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/8/8.0.0/Makefile b/linux/ecosystem/atlassian/confluence/8/8.0.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.0.0/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.0.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/8/8.0.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/8/8.0.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/8/8.0.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/8/8.0.0/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.0.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.0.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/8/8.0.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/8/8.0.1/Makefile b/linux/ecosystem/atlassian/confluence/8/8.0.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.0.1/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.0.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/8/8.0.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/8/8.0.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/8/8.0.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/8/8.0.1/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.0.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.0.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/8/8.0.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/8/8.0.2/Makefile b/linux/ecosystem/atlassian/confluence/8/8.0.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.0.2/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.0.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/8/8.0.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/8/8.0.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/8/8.0.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/8/8.0.2/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.0.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.0.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/8/8.0.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/8/8.4.0/Makefile b/linux/ecosystem/atlassian/confluence/8/8.4.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.4.0/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.4.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/8/8.4.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/8/8.4.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/8/8.4.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/8/8.4.0/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.4.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.4.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/8/8.4.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/8/8.5.3/Makefile b/linux/ecosystem/atlassian/confluence/8/8.5.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.5.3/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.5.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/8/8.5.3/kaniko-build.py b/linux/ecosystem/atlassian/confluence/8/8.5.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/8/8.5.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/8/8.5.3/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.5.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.5.3/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/8/8.5.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/8/8.6.1/Makefile b/linux/ecosystem/atlassian/confluence/8/8.6.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.6.1/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.6.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/8/8.6.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/8/8.6.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/8/8.6.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/8/8.6.1/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.6.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.6.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/8/8.6.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/8/8.7.2/Makefile b/linux/ecosystem/atlassian/confluence/8/8.7.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.7.2/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.7.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/8/8.7.2/kaniko-build.py b/linux/ecosystem/atlassian/confluence/8/8.7.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/8/8.7.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/8/8.7.2/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.7.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.7.2/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/8/8.7.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/8/8.8.1/Makefile b/linux/ecosystem/atlassian/confluence/8/8.8.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.8.1/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.8.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/8/8.8.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/8/8.8.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/8/8.8.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/8/8.8.1/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.8.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.8.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/8/8.8.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/8/8.9.5/Makefile b/linux/ecosystem/atlassian/confluence/8/8.9.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.9.5/Makefile +++ b/linux/ecosystem/atlassian/confluence/8/8.9.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/8/8.9.5/kaniko-build.py b/linux/ecosystem/atlassian/confluence/8/8.9.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/8/8.9.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/8/8.9.5/requirements.txt b/linux/ecosystem/atlassian/confluence/8/8.9.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/8/8.9.5/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/8/8.9.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.0/Makefile b/linux/ecosystem/atlassian/confluence/9/9.0.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/9/9.0.0/Makefile +++ b/linux/ecosystem/atlassian/confluence/9/9.0.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.0/kaniko-build.py b/linux/ecosystem/atlassian/confluence/9/9.0.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/9/9.0.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.0/requirements.txt b/linux/ecosystem/atlassian/confluence/9/9.0.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/9/9.0.0/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/9/9.0.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.1/Makefile b/linux/ecosystem/atlassian/confluence/9/9.0.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/9/9.0.1/Makefile +++ b/linux/ecosystem/atlassian/confluence/9/9.0.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.1/kaniko-build.py b/linux/ecosystem/atlassian/confluence/9/9.0.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/9/9.0.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/9/9.0.1/requirements.txt b/linux/ecosystem/atlassian/confluence/9/9.0.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/9/9.0.1/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/9/9.0.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/latest/Makefile b/linux/ecosystem/atlassian/confluence/latest/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/latest/Makefile +++ b/linux/ecosystem/atlassian/confluence/latest/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/latest/kaniko-build.py b/linux/ecosystem/atlassian/confluence/latest/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/latest/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/latest/requirements.txt b/linux/ecosystem/atlassian/confluence/latest/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/latest/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/latest/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/templates/5/Makefile b/linux/ecosystem/atlassian/confluence/templates/5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/templates/5/Makefile +++ b/linux/ecosystem/atlassian/confluence/templates/5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/templates/5/kaniko-build.py b/linux/ecosystem/atlassian/confluence/templates/5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/templates/5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/templates/5/requirements.txt b/linux/ecosystem/atlassian/confluence/templates/5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/templates/5/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/templates/5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/confluence/templates/6/Makefile b/linux/ecosystem/atlassian/confluence/templates/6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/confluence/templates/6/Makefile +++ b/linux/ecosystem/atlassian/confluence/templates/6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/confluence/templates/6/kaniko-build.py b/linux/ecosystem/atlassian/confluence/templates/6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/confluence/templates/6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/confluence/templates/6/requirements.txt b/linux/ecosystem/atlassian/confluence/templates/6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/confluence/templates/6/requirements.txt +++ b/linux/ecosystem/atlassian/confluence/templates/6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crowd/5/5.1.1/Makefile b/linux/ecosystem/atlassian/crowd/5/5.1.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/crowd/5/5.1.1/Makefile +++ b/linux/ecosystem/atlassian/crowd/5/5.1.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/crowd/5/5.1.1/kaniko-build.py b/linux/ecosystem/atlassian/crowd/5/5.1.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crowd/5/5.1.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crowd/5/5.1.1/requirements.txt b/linux/ecosystem/atlassian/crowd/5/5.1.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crowd/5/5.1.1/requirements.txt +++ b/linux/ecosystem/atlassian/crowd/5/5.1.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crowd/latest/Makefile b/linux/ecosystem/atlassian/crowd/latest/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/crowd/latest/Makefile +++ b/linux/ecosystem/atlassian/crowd/latest/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/crowd/latest/kaniko-build.py b/linux/ecosystem/atlassian/crowd/latest/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crowd/latest/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crowd/latest/requirements.txt b/linux/ecosystem/atlassian/crowd/latest/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crowd/latest/requirements.txt +++ b/linux/ecosystem/atlassian/crowd/latest/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.0.3/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.0.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.0.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.0.3/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.0.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.0.3/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.0.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.0.4/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.0.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.0.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.0.4/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.0.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.0.4/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.0.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.0/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.0/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.0/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.1.1/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.1.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.1.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.1.1/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.1.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.1.1/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.1.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.1.2/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.1.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.1.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.1.2/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.1.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.1.2/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.1.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.1.3/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.1.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.1.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.1.3/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.1.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.1.3/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.1.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.1.4/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.1.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.1.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.1.4/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.1.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.1.4/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.1.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.1/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.1/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.1/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.2.1/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.2.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.2.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.2.1/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.2.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.2.1/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.2.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.2.2/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.2.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.2.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.2.2/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.2.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.2.2/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.2.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.2.3/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.2.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.2.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.2.3/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.2.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.2.3/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.2.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.2/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.2/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.2/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.5.1/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.5.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.5.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.5.1/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.5.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.5.1/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.5.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.5.2/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.5.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.5.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.5.2/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.5.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.5.2/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.5.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.5.3/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.5.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.5.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.5.3/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.5.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.5.3/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.5.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.5.4/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.5.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.5.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.5.4/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.5.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.5.4/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.5.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.5/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.5/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.5/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.0/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.6.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.6.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.0/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.6.0/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.6.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.0Beta1/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.6.0Beta1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.6.0Beta1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.0Beta1/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.0Beta1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.6.0Beta1/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.6.0Beta1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.0Beta2/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.6.0Beta2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.6.0Beta2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.0Beta2/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.0Beta2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.6.0Beta2/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.6.0Beta2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.1/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.6.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.6.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.1/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.6.1/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.6.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.2.1/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.6.2.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.6.2.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.2.1/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.2.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.6.2.1/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.6.2.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.2/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.6.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.6.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.2/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.6.2/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.6.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.3/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.6.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.6.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.3/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.6.3/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.6.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.4/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.6.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.6.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.4/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.6.4/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.6.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.5.a/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.6.5.a/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.6.5.a/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.5.a/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.5.a/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.6.5.a/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.6.5.a/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.5/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.6.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.6.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.5/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.6.5/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.6.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.5a/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.6.5a/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.6.5a/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.5a/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.5a/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.6.5a/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.6.5a/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.6/kaniko-build.py b/linux/ecosystem/atlassian/crucible/1/1.6.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/1/1.6.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/1/1.6.6/requirements.txt b/linux/ecosystem/atlassian/crucible/1/1.6.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/1/1.6.6/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/1/1.6.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/crucible/templates/1/Makefile b/linux/ecosystem/atlassian/crucible/templates/1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/crucible/templates/1/Makefile +++ b/linux/ecosystem/atlassian/crucible/templates/1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/crucible/templates/1/kaniko-build.py b/linux/ecosystem/atlassian/crucible/templates/1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/crucible/templates/1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/crucible/templates/1/requirements.txt b/linux/ecosystem/atlassian/crucible/templates/1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/crucible/templates/1/requirements.txt +++ b/linux/ecosystem/atlassian/crucible/templates/1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.B3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.B3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.B3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.B3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.B3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.B3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.B3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0.RC3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.6/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.6/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.0.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.M2cc/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.M2cc/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.M2cc/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.M2cc/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.M2cc/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.M2cc/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.M2cc/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.RC1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.RC1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.RC1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.RC1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.RC1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.RC1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0.RC1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.1.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.6/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.6/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.7/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.7/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.8/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.8/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.8/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.10.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.2.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.6/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.6/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.7/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.7/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.8/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.8/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.8/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.3.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.6/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.6/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.4.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.6/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.6/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.7/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.7/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.8/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.8/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.8/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.9/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.9/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.9/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.5.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.6/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.6/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.7/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.7/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.8/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.8/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.8/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.9/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.9/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.9/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.6.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0-EAP-2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.10/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.10/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.10/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.11/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.11/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.11/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.12/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.12/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.12/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.13/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.13/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.13/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.14/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.14/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.14/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.15/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.15/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.15/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.6/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.6/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.7/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.7/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.8/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.8/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.8/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.9/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.9/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.9/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.7.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0-m1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0-m1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0-m1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0-m1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0-m1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0-m1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0-m1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.8.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/2/2.9.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.0.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.6/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.6/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.7/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.7/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.1.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.10.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.2.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.3.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.6/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.6/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.7/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.7/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.4.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.5.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.6.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.7.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.8.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/3/3.9.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.0.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.1.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.2.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.3.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.6/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.6/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.7/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.7/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.7/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.4.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.5.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.6.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.7.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.0/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.1/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.5/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.6/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.6/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.6/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/4/4.8.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/latest/Makefile b/linux/ecosystem/atlassian/fisheye-crucible/latest/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/latest/Makefile +++ b/linux/ecosystem/atlassian/fisheye-crucible/latest/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/fisheye-crucible/latest/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/latest/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/latest/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/latest/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/latest/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/latest/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/latest/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/templates/2/Makefile b/linux/ecosystem/atlassian/fisheye-crucible/templates/2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/templates/2/Makefile +++ b/linux/ecosystem/atlassian/fisheye-crucible/templates/2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/fisheye-crucible/templates/2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/templates/2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/templates/2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/templates/2/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/templates/2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/templates/2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/templates/2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/templates/3/Makefile b/linux/ecosystem/atlassian/fisheye-crucible/templates/3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/templates/3/Makefile +++ b/linux/ecosystem/atlassian/fisheye-crucible/templates/3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/fisheye-crucible/templates/3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/templates/3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/templates/3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/templates/3/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/templates/3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/templates/3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/templates/3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye-crucible/templates/4/Makefile b/linux/ecosystem/atlassian/fisheye-crucible/templates/4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/templates/4/Makefile +++ b/linux/ecosystem/atlassian/fisheye-crucible/templates/4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/fisheye-crucible/templates/4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye-crucible/templates/4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye-crucible/templates/4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye-crucible/templates/4/requirements.txt b/linux/ecosystem/atlassian/fisheye-crucible/templates/4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye-crucible/templates/4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye-crucible/templates/4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.0.1a/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.0.1a/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.0.1a/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.0.1a/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.0.1a/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.0.1a/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.0.1a/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.1.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.1.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.1.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.1.3/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.1.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.1.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.1.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.2.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.2.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.2.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.2.5/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.2.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.2.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.2.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.3.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.3.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.3.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.3.3/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.3.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.3.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.3.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.3.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.3.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.3.4/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.3.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.3.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.3.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.3.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.3.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.3.5/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.3.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.3.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.3.6/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.3.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.3.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.3.6/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.3.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.3.6/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.3.7/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.3.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.3.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.3.7/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.3.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.3.7/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.3.8/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.3.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.3.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.3.8/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.3.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.3.8/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.3.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.4.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.4.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.4.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.4.1/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.4.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.4.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.4.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.4.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.4.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.4.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.4.2/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.4.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.4.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.4.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.4.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.4.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.4.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.4.3/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.4.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.4.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.4.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.4/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.5.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.5.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.5.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.5.1/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.5.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.5.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.5.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.5.2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.5.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.5.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.5.2/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.5.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.5.2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.5.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.5.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.5.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.5.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.5.3/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.5.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.5.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.5.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.5.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.5.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.5.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.5.4/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.5.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.5.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.5.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.5/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.0/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.6.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.0/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.0/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta1/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta2/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta2/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta2/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.0Beta2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.6.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.1/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.3/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.6.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.3/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.3/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.4/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.6.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.4/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.4/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.5.a/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.6.5.a/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.5.a/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.5.a/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.5.a/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.5.a/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.5.a/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.5/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.6.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.5/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.5/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.5a/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.6.5a/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.5a/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.5a/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.5a/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.5a/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.5a/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.6/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/1/1.6.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/1/1.6.6/requirements.txt b/linux/ecosystem/atlassian/fisheye/1/1.6.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/1/1.6.6/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/1/1.6.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/fisheye/templates/1/Makefile b/linux/ecosystem/atlassian/fisheye/templates/1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/fisheye/templates/1/Makefile +++ b/linux/ecosystem/atlassian/fisheye/templates/1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/fisheye/templates/1/kaniko-build.py b/linux/ecosystem/atlassian/fisheye/templates/1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/fisheye/templates/1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/fisheye/templates/1/requirements.txt b/linux/ecosystem/atlassian/fisheye/templates/1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/fisheye/templates/1/requirements.txt +++ b/linux/ecosystem/atlassian/fisheye/templates/1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.1.1/Makefile b/linux/ecosystem/atlassian/jira/4/4.1.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.1.1/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.1.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.1.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.1.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.1.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.1.1/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.1.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.1.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.1.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.1.2/Makefile b/linux/ecosystem/atlassian/jira/4/4.1.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.1.2/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.1.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.1.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.1.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.1.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.1.2/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.1.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.1.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.1.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.2.1/Makefile b/linux/ecosystem/atlassian/jira/4/4.2.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.2.1/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.2.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.2.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.2.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.2.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.2.1/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.2.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.2.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.2.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.2.2/Makefile b/linux/ecosystem/atlassian/jira/4/4.2.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.2.2/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.2.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.2.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.2.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.2.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.2.2/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.2.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.2.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.2.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.2.3/Makefile b/linux/ecosystem/atlassian/jira/4/4.2.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.2.3/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.2.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.2.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.2.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.2.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.2.3/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.2.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.2.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.2.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.2.4/Makefile b/linux/ecosystem/atlassian/jira/4/4.2.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.2.4/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.2.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.2.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.2.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.2.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.2.4/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.2.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.2.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.2.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.2/Makefile b/linux/ecosystem/atlassian/jira/4/4.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.2/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.2/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.3.1/Makefile b/linux/ecosystem/atlassian/jira/4/4.3.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.3.1/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.3.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.3.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.3.1/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.3.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.3.2/Makefile b/linux/ecosystem/atlassian/jira/4/4.3.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.3.2/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.3.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.3.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.3.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.3.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.3.2/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.3.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.3.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.3.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.3.3/Makefile b/linux/ecosystem/atlassian/jira/4/4.3.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.3.3/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.3.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.3.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.3.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.3.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.3.3/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.3.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.3.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.3.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.3.4/Makefile b/linux/ecosystem/atlassian/jira/4/4.3.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.3.4/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.3.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.3.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.3.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.3.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.3.4/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.3.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.3.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.3.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.3/Makefile b/linux/ecosystem/atlassian/jira/4/4.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.3/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.3/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.4.1/Makefile b/linux/ecosystem/atlassian/jira/4/4.4.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.4.1/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.4.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.4.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.4.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.4.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.4.1/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.4.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.4.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.4.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.4.3/Makefile b/linux/ecosystem/atlassian/jira/4/4.4.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.4.3/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.4.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.4.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.4.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.4.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.4.3/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.4.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.4.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.4.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.4.4/Makefile b/linux/ecosystem/atlassian/jira/4/4.4.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.4.4/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.4.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.4.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.4.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.4.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.4.4/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.4.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.4.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.4.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.4.5/Makefile b/linux/ecosystem/atlassian/jira/4/4.4.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.4.5/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.4.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.4.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.4.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.4.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.4.5/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.4.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.4.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.4.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/4/4.4/Makefile b/linux/ecosystem/atlassian/jira/4/4.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/4/4.4/Makefile +++ b/linux/ecosystem/atlassian/jira/4/4.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/4/4.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/4/4.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/4/4.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/4/4.4/requirements.txt b/linux/ecosystem/atlassian/jira/4/4.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/4/4.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/4/4.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.0.1/Makefile b/linux/ecosystem/atlassian/jira/5/5.0.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.1/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.0.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.0.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.0.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.0.1/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.0.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.0.2/Makefile b/linux/ecosystem/atlassian/jira/5/5.0.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.2/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.0.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.0.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.0.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.0.2/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.0.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.0.3/Makefile b/linux/ecosystem/atlassian/jira/5/5.0.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.3/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.0.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.0.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.0.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.0.3/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.0.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.0.4/Makefile b/linux/ecosystem/atlassian/jira/5/5.0.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.4/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.0.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.0.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.0.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.0.4/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.0.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.0.5/Makefile b/linux/ecosystem/atlassian/jira/5/5.0.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.5/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.0.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.0.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.0.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.0.5/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.0.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.0.6/Makefile b/linux/ecosystem/atlassian/jira/5/5.0.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.6/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.0.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.0.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.0.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.0.6/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.0.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.0.7/Makefile b/linux/ecosystem/atlassian/jira/5/5.0.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.7/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.0.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.0.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.0.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.0.7/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.0.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.0/Makefile b/linux/ecosystem/atlassian/jira/5/5.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.0/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.1.1/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.1/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.1.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.1.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.1.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.1.1/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.1.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.1.2/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.2/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.1.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.1.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.1.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.1.2/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.1.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.1.3/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.3/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.1.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.1.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.1.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.1.3/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.1.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.1.4/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.4/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.1.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.1.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.1.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.1.4/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.1.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.1.5/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.5/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.1.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.1.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.1.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.1.5/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.1.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.1.6/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.6/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.1.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.1.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.1.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.1.6/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.1.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.1.7/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.7/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.1.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.1.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.1.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.1.7/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.1.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.1.8/Makefile b/linux/ecosystem/atlassian/jira/5/5.1.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.8/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.1.8/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.1.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.1.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.1.8/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1.8/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.1.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.1/Makefile b/linux/ecosystem/atlassian/jira/5/5.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.1/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.2.1/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.1/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.2.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.2.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.2.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.2.1/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.2.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.2.10/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.10/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.2.10/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.2.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.2.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.2.10/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.10/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.2.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.2.11/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.11/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.2.11/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.2.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.2.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.2.11/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.11/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.2.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.2.2/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.2/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.2.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.2.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.2.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.2.2/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.2.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.2.3/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.3/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.2.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.2.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.2.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.2.3/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.2.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.2.4.1/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.4.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.4.1/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.4.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.2.4.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.2.4.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.2.4.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.2.4.1/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.4.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.4.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.2.4.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.2.4/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.4/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.2.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.2.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.2.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.2.4/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.2.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.2.5/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.5/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.2.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.2.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.2.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.2.5/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.2.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.2.6/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.6/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.2.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.2.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.2.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.2.6/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.2.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.2.7/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.7/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.2.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.2.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.2.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.2.7/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.2.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.2.8/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.8/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.2.8/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.2.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.2.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.2.8/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.8/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.2.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.2.9/Makefile b/linux/ecosystem/atlassian/jira/5/5.2.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.9/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.2.9/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.2.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.2.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.2.9/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2.9/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.2.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/5/5.2/Makefile b/linux/ecosystem/atlassian/jira/5/5.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2/Makefile +++ b/linux/ecosystem/atlassian/jira/5/5.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/5/5.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/5/5.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/5/5.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/5/5.2/requirements.txt b/linux/ecosystem/atlassian/jira/5/5.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/5/5.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/5/5.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.0.1/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.1/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.0.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.0.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.0.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.0.1/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.0.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.0.2/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.2/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.0.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.0.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.0.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.0.2/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.0.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.0.3/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.3/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.0.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.0.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.0.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.0.3/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.0.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.0.4/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.4/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.0.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.0.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.0.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.0.4/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.0.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.0.5/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.5/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.0.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.0.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.0.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.0.5/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.0.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.0.6/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.6/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.0.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.0.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.0.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.0.6/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.0.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.0.7/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.7/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.0.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.0.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.0.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.0.7/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.0.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.0.8/Makefile b/linux/ecosystem/atlassian/jira/6/6.0.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.8/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.0.8/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.0.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.0.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.0.8/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0.8/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.0.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.0/Makefile b/linux/ecosystem/atlassian/jira/6/6.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.0/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.1.1/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.1/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.1.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.1.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.1.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.1.1/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.1.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.1.2/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.2/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.1.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.1.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.1.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.1.2/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.1.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.1.3/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.3/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.1.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.1.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.1.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.1.3/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.1.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.1.4/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.4/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.1.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.1.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.1.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.1.4/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.1.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.1.5/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.5/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.1.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.1.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.1.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.1.5/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.1.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.1.6/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.6/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.1.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.1.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.1.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.1.6/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.1.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.1.7/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.7/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.1.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.1.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.1.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.1.7/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.1.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.1.8/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.8/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.1.8/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.1.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.1.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.1.8/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.8/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.1.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.1.9/Makefile b/linux/ecosystem/atlassian/jira/6/6.1.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.9/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.1.9/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.1.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.1.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.1.9/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1.9/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.1.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.1/Makefile b/linux/ecosystem/atlassian/jira/6/6.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.1/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.2.1/Makefile b/linux/ecosystem/atlassian/jira/6/6.2.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.1/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.2.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.2.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.2.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.2.1/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.2.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.2.2/Makefile b/linux/ecosystem/atlassian/jira/6/6.2.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.2/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.2.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.2.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.2.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.2.2/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.2.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.2.3/Makefile b/linux/ecosystem/atlassian/jira/6/6.2.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.3/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.2.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.2.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.2.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.2.3/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.2.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.2.4/Makefile b/linux/ecosystem/atlassian/jira/6/6.2.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.4/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.2.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.2.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.2.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.2.4/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.2.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.2.5/Makefile b/linux/ecosystem/atlassian/jira/6/6.2.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.5/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.2.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.2.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.2.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.2.5/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.2.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.2.6/Makefile b/linux/ecosystem/atlassian/jira/6/6.2.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.6/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.2.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.2.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.2.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.2.6/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.2.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.2.7/Makefile b/linux/ecosystem/atlassian/jira/6/6.2.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.7/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.2.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.2.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.2.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.2.7/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.2.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.2/Makefile b/linux/ecosystem/atlassian/jira/6/6.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.2/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.3.1/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.1/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.3.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.3.1/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.3.10/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.10/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.3.10/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.3.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.3.10/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.10/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.3.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.3.11/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.11/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.3.11/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.3.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.3.11/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.11/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.3.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.3.12/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.12/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.3.12/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.3.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.3.12/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.12/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.3.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.3.13/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.13/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.13/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.13/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.3.13/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3.13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.3.13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.3.13/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.13/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.3.13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.3.14/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.14/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.14/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.14/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.3.14/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3.14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.3.14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.3.14/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.14/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.3.14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.3.15/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.15/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.15/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.15/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.3.15/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3.15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.3.15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.3.15/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.15/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.3.15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.3.3/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.3/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.3.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.3.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.3.3/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.3.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.3.4/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.4/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.3.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.3.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.3.4/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.3.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.3.5/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.5/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.3.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.3.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.3.5/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.3.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.3.6/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.6/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.3.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.3.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.3.6/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.3.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.3.7/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.7/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.3.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.3.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.3.7/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.3.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.3.8/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.8/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.3.8/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.3.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.3.8/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.8/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.3.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.3.9/Makefile b/linux/ecosystem/atlassian/jira/6/6.3.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.9/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.3.9/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.3.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.3.9/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3.9/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.3.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.3/Makefile b/linux/ecosystem/atlassian/jira/6/6.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.3/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.4.1/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.1/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.4.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.4.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.4.1/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.4.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.4.10/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.10/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.4.10/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.4.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.4.10/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.10/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.4.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.4.11/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.11/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.4.11/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.4.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.4.11/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.11/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.4.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.4.12/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.12/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.4.12/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.4.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.4.12/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.12/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.4.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.4.13/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.13/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.13/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.13/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.4.13/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4.13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.4.13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.4.13/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.13/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.4.13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.4.14/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.14/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.14/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.14/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.4.14/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4.14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.4.14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.4.14/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.14/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.4.14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.4.2/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.2/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.4.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.4.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.4.2/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.4.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.4.3/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.3/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.4.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.4.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.4.3/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.4.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.4.4/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.4/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.4.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.4.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.4.4/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.4.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.4.5/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.5/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.4.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.4.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.4.5/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.4.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.4.6/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.6/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.4.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.4.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.4.6/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.4.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.4.7/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.7/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.4.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.4.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.4.7/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.4.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.4.8/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.8/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.4.8/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.4.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.4.8/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.8/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.4.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.4.9/Makefile b/linux/ecosystem/atlassian/jira/6/6.4.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.9/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.4.9/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.4.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.4.9/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4.9/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.4.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/6/6.4/Makefile b/linux/ecosystem/atlassian/jira/6/6.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4/Makefile +++ b/linux/ecosystem/atlassian/jira/6/6.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/6/6.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/6/6.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/6/6.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/6/6.4/requirements.txt b/linux/ecosystem/atlassian/jira/6/6.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/6/6.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/6/6.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.0.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.0.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.0.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.0.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.0.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.0.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.0.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.0.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.0.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.0.10/Makefile b/linux/ecosystem/atlassian/jira/7/7.0.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.10/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.0.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.0.10/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.0.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.0.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.0.10/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.0.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.10/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.0.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.0.11/Makefile b/linux/ecosystem/atlassian/jira/7/7.0.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.11/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.0.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.0.11/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.0.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.0.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.0.11/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.0.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.11/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.0.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.0.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.0.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.0.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.0.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.0.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.0.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.0.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.0.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.0.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.0.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.0.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.0.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.0.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.0.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.0.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.0.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.0.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.0.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.0.5/Makefile b/linux/ecosystem/atlassian/jira/7/7.0.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.5/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.0.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.0.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.0.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.0.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.0.5/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.0.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.0.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.0.9/Makefile b/linux/ecosystem/atlassian/jira/7/7.0.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.9/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.0.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.0.9/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.0.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.0.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.0.9/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.0.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.0.9/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.0.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.1.0-m01/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.0-m01/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.0-m01/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.0-m01/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.1.0-m01/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.1.0-m01/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.1.0-m01/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.1.0-m01/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.0-m01/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.0-m01/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.1.0-m01/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.1.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.1.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.1.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.1.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.1.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.1.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.1.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.1.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.1.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.1.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.1.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.1.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.1.10/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.10/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.1.10/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.1.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.1.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.1.10/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.10/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.1.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.1.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.1.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.1.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.1.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.1.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.1.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.1.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.1.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.1.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.1.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.1.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.1.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.1.6/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.6/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.1.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.1.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.1.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.1.6/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.1.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.1.7/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.7/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.1.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.1.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.1.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.1.7/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.1.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.1.8/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.8/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.1.8/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.1.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.1.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.1.8/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.8/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.1.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.1.9/Makefile b/linux/ecosystem/atlassian/jira/7/7.1.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.9/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.1.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.1.9/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.1.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.1.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.1.9/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.1.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.1.9/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.1.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.10.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.10.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.10.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.10.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.10.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.10.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.10.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.10.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.10.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.10.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.10.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.10.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.10.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.10.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.10.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.10.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.10.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.10.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.10.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.10.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.10.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.10.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.10.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.10.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.10.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.10.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.10.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.10.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.10.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.10.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.10.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.10.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.10.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.11.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.11.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.11.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.11.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.11.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.11.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.11.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.11.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.11.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.11.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.11.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.11.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.11.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.11.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.11.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.11.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.11.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.11.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.11.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.11.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.11.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.11.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.11.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.11.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.11.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.11.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.11.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.11.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.11.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.11.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.11.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.11.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.11.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.12.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.12.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.12.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.12.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.12.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.12.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.12.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.12.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.12.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.12.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.12.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.12.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.12.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.12.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.12.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.12.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.12.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.12.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.12.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.12.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.12.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.12.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.12.3/Makefile b/linux/ecosystem/atlassian/jira/7/7.12.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.12.3/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.12.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.12.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.12.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.12.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.12.3/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.12.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.12.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.12.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.11/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.11/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.11/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.11/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.11/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.12/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.12/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.12/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.12/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.12/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.13/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.13/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.13/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.13/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.13/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.13/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.13/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.14/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.14/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.14/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.14/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.14/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.14/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.14/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.15/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.15/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.15/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.15/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.15/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.15/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.15/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.16/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.16/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.16/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.16/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.16/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.17/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.17/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.17/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.17/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.17/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.18/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.18/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.18/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.18/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.18/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.3/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.3/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.3/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.5/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.5/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.5/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.6/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.6/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.6/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.8/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.8/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.8/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.8/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.8/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.13.9/Makefile b/linux/ecosystem/atlassian/jira/7/7.13.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.9/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.13.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.13.9/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.13.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.13.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.13.9/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.13.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.13.9/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.13.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.2.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.2.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.2.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.2.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.2.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.2.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.2.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.2.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.2.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.2.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.2.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.2.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.2.10/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.10/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.2.10/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.2.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.2.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.2.10/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.10/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.2.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.2.11/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.11/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.2.11/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.2.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.2.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.2.11/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.11/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.2.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.2.12/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.12/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.2.12/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.2.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.2.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.2.12/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.12/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.2.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.2.13/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.13/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.13/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.13/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.2.13/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.2.13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.2.13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.2.13/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.13/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.2.13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.2.14/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.14/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.14/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.14/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.2.14/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.2.14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.2.14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.2.14/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.14/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.2.14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.2.15/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.15/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.15/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.15/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.2.15/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.2.15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.2.15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.2.15/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.15/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.2.15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.2.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.2.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.2.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.2.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.2.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.2.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.2.3/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.3/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.2.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.2.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.2.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.2.3/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.2.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.2.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.2.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.2.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.2.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.2.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.2.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.2.6/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.6/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.2.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.2.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.2.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.2.6/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.2.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.2.7/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.7/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.2.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.2.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.2.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.2.7/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.2.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.2.8/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.8/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.2.8/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.2.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.2.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.2.8/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.8/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.2.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.2.9/Makefile b/linux/ecosystem/atlassian/jira/7/7.2.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.9/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.2.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.2.9/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.2.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.2.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.2.9/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.2.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.2.9/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.2.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.3.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.3.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.3.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.3.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.3.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.3.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.3.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.3.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.3.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.3.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.3.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.3.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.3.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.3.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.3.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.3.3/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.3/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.3.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.3.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.3.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.3.3/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.3.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.3.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.3.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.3.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.3.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.3.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.3.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.3.5/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.5/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.3.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.3.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.3.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.3.5/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.3.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.3.6/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.6/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.3.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.3.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.3.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.3.6/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.3.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.3.7/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.7/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.3.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.3.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.3.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.3.7/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.3.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.3.8/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.8/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.3.8/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.3.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.3.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.3.8/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.8/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.3.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.3.9/Makefile b/linux/ecosystem/atlassian/jira/7/7.3.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.9/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.3.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.3.9/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.3.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.3.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.3.9/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.3.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.3.9/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.3.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.4.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.4.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.4.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.4.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.4.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.4.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.4.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.4.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.4.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.4.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.4.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.4.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.4.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.4.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.4.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.4.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.4.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.4.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.4.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.4.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.4.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.4.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.4.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.4.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.4.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.4.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.4.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.4.3/Makefile b/linux/ecosystem/atlassian/jira/7/7.4.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.3/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.4.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.4.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.4.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.4.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.4.3/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.4.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.4.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.4.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.4.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.4.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.4.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.4.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.4.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.4.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.4.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.4.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.4.5/Makefile b/linux/ecosystem/atlassian/jira/7/7.4.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.5/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.4.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.4.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.4.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.4.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.4.5/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.4.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.4.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.4.6/Makefile b/linux/ecosystem/atlassian/jira/7/7.4.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.6/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.4.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.4.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.4.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.4.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.4.6/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.4.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.4.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.4.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.5.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.5.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.5.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.5.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.5.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.5.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.5.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.5.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.5.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.5.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.5.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.5.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.5.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.5.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.5.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.5.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.5.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.5.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.5.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.5.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.5.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.5.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.5.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.5.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.5.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.5.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.5.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.5.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.5.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.5.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.5.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.5.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.5.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.5.3/Makefile b/linux/ecosystem/atlassian/jira/7/7.5.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.5.3/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.5.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.5.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.5.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.5.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.5.3/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.5.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.5.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.5.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.5.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.5.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.5.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.5.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.5.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.5.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.5.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.5.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.5.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.5.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.5.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.10/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.10/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.10/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.10/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.10/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.11/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.11/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.11/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.11/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.11/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.12/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.12/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.12/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.12/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.12/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.13/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.13/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.13/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.13/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.13/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.13/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.13/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.14/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.14/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.14/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.14/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.14/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.14/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.14/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.15/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.15/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.15/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.15/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.15/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.15/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.15/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.16/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.16/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.16/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.16/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.16/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.17/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.17/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.17/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.17/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.17/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.3/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.3/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.3/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.6/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.6/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.6/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.7/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.7/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.7/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.8/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.8/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.8/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.8/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.8/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.6.9/Makefile b/linux/ecosystem/atlassian/jira/7/7.6.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.9/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.6.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.6.9/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.6.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.6.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.6.9/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.6.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.6.9/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.6.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.7.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.7.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.7.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.7.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.7.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.7.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.7.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.7.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.7.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.7.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.7.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.7.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.7.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.7.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.7.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.7.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.7.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.7.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.7.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.7.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.7.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.7.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.7.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.7.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.7.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.7.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.7.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.7.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.7.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.7.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.7.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.7.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.7.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.7.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.7.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.7.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.7.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.7.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.7.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.7.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.7.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.7.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.7.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.7.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.8.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.8.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.8.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.8.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.8.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.8.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.8.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.8.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.8.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.8.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.8.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.8.1/Makefile b/linux/ecosystem/atlassian/jira/7/7.8.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.8.1/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.8.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.8.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.8.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.8.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.8.1/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.8.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.8.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.8.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.8.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.8.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.8.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.8.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.8.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.8.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.8.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.8.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.8.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.8.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.8.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.8.4/Makefile b/linux/ecosystem/atlassian/jira/7/7.8.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.8.4/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.8.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.8.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.8.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.8.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.8.4/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.8.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.8.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.8.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.9.0/Makefile b/linux/ecosystem/atlassian/jira/7/7.9.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.9.0/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.9.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.9.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.9.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.9.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.9.0/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.9.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.9.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.9.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/7/7.9.2/Makefile b/linux/ecosystem/atlassian/jira/7/7.9.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/7/7.9.2/Makefile +++ b/linux/ecosystem/atlassian/jira/7/7.9.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/7/7.9.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/7/7.9.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/7/7.9.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/7/7.9.2/requirements.txt b/linux/ecosystem/atlassian/jira/7/7.9.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/7/7.9.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/7/7.9.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.0.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.0.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.0.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.0.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.0.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.0.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.0.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.0.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.0.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.0.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.0.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.0.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.0.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.0.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.0.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.0.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.0.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.0.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.0.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.0.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.0.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.0.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.0.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.0.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.0.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.0.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.0.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.0.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.0.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.0.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.0.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.0.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.0.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.1.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.1.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.1.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.1.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.1.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.1.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.1.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.1.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.1.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.1.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.1.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.1.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.1.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.1.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.1.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.1.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.1.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.1.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.1.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.1.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.1.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.1.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.1.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.1.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.1.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.1.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.1.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.1.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.1.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.1.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.1.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.1.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.1.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.1.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.1.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.1.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.1.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.1.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.1.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.1.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.1.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.1.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.1.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.1.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.10.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.10.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.10.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.10.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.10.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.10.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.10.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.10.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.10.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.10.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.10.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.10.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.10.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.10.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.10.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.10.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.10.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.10.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.10.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.10.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.10.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.10.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.11.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.11.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.11.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.11.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.11.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.11.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.11.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.11.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.11.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.11.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.11.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.11.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.11.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.11.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.11.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.11.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.11.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.11.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.11.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.11.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.11.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.11.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.12.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.12.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.12.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.12.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.12.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.12.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.12.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.12.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.12.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.12.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.12.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.12.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.12.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.12.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.12.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.12.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.12.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.12.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.12.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.12.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.12.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.12.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.12.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.12.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.12.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.12.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.12.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.12.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.12.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.12.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.12.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.12.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.12.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.12.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.12.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.12.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.12.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.12.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.12.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.12.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.12.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.12.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.12.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.12.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.10/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.10/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.10/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.10/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.10/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.11/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.11/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.11/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.11/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.11/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.12/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.12/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.12/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.12/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.12/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.13/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.13/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.13/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.13/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.13/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.13/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.13/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.14/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.14/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.14/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.14/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.14/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.14/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.14/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.15/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.15/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.15/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.15/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.15/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.15/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.15/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.16/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.16/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.16/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.16/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.16/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.17/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.17/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.17/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.17/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.17/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.18/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.18/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.18/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.18/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.18/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.19/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.19/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.19/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.19/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.19/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.20/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.20/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.20/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.20/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.20/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.20/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.20/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.21/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.21/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.21/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.21/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.21/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.22/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.22/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.22/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.22/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.22/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.22/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.22/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.22/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.22/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.22/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.22/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.24/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.24/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.24/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.24/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.24/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.24/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.24/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.24/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.24/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.24/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.24/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.25/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.25/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.25/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.25/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.25/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.25/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.25/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.25/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.25/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.25/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.25/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.26/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.26/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.26/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.26/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.26/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.26/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.26/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.26/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.26/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.26/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.26/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.27/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.27/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.27/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.27/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.27/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.27/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.27/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.27/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.27/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.27/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.27/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.4/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.4/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.4/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.5/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.5/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.5/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.6/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.6/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.6/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.7/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.7/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.7/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.8/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.8/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.8/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.8/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.8/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.13.9/Makefile b/linux/ecosystem/atlassian/jira/8/8.13.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.9/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.13.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.13.9/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.13.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.13.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.13.9/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.13.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.13.9/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.13.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.14.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.14.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.14.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.14.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.14.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.14.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.14.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.14.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.14.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.14.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.14.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.14.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.14.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.14.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.14.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.14.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.14.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.14.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.14.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.14.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.14.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.14.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.15.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.15.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.15.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.15.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.15.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.15.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.15.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.15.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.15.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.15.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.15.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.15.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.15.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.15.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.15.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.15.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.15.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.15.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.15.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.15.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.15.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.15.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.16.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.16.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.16.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.16.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.16.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.16.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.16.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.16.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.16.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.16.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.16.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.16.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.16.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.16.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.16.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.16.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.16.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.16.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.16.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.16.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.16.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.16.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.16.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.16.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.16.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.16.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.16.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.16.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.16.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.16.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.16.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.16.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.16.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.17.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.17.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.17.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.17.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.17.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.17.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.17.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.17.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.17.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.17.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.17.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.17.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.17.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.17.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.17.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.17.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.17.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.17.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.17.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.17.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.17.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.17.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.18.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.18.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.18.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.18.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.18.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.18.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.18.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.18.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.18.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.18.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.18.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.18.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.18.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.18.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.18.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.18.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.18.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.18.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.18.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.18.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.18.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.18.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.19.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.19.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.19.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.19.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.19.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.19.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.19.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.19.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.19.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.19.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.19.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.19.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.19.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.19.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.19.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.19.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.19.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.19.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.19.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.19.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.19.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.19.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.2.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.2.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.2.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.2.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.2.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.2.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.2.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.2.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.2.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.2.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.2.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.2.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.2.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.2.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.2.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.2.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.2.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.2.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.2.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.2.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.2.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.2.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.2.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.2.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.2.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.2.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.2.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.2.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.2.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.2.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.2.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.2.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.2.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.2.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.2.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.2.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.2.4/Makefile b/linux/ecosystem/atlassian/jira/8/8.2.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.4/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.2.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.2.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.2.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.2.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.2.4/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.2.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.2.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.2.5/Makefile b/linux/ecosystem/atlassian/jira/8/8.2.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.5/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.2.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.2.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.2.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.2.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.2.5/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.2.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.2.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.2.6/Makefile b/linux/ecosystem/atlassian/jira/8/8.2.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.6/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.2.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.2.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.2.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.2.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.2.6/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.2.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.2.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.2.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.10/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.10/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.10/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.10/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.10/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.11/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.11/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.11/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.11/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.11/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.12/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.12/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.12/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.12/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.12/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.13/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.13/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.13/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.13/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.13/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.13/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.13/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.14/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.14/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.14/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.14/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.14/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.14/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.14/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.15/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.15/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.15/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.15/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.15/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.15/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.15/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.16/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.16/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.16/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.16/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.16/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.17/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.17/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.17/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.17/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.17/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.19/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.19/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.19/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.19/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.19/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.20/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.20/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.20/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.20/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.20/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.20/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.20/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.21/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.21/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.21/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.21/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.21/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.22/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.22/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.22/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.22/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.22/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.22/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.22/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.22/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.22/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.22/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.22/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.23/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.23/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.23/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.23/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.23/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.23/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.23/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.23/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.23/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.23/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.23/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.24/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.24/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.24/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.24/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.24/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.24/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.24/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.24/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.24/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.24/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.24/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.25/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.25/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.25/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.25/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.25/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.25/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.25/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.25/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.25/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.25/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.25/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.26/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.26/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.26/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.26/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.26/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.26/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.26/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.26/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.26/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.26/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.26/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.27/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.27/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.27/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.27/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.27/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.27/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.27/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.27/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.27/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.27/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.27/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.28/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.28/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.28/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.28/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.28/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.28/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.28/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.28/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.28/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.28/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.28/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.29/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.29/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.29/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.29/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.29/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.29/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.29/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.29/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.29/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.29/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.29/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.30/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.30/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.30/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.30/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.30/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.30/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.30/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.30/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.30/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.30/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.30/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.4/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.4/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.4/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.5/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.5/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.5/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.6/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.6/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.6/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.7/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.7/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.7/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.8/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.8/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.8/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.8/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.8/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.20.9/Makefile b/linux/ecosystem/atlassian/jira/8/8.20.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.9/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.20.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.20.9/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.20.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.20.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.20.9/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.20.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.20.9/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.20.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.21.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.21.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.21.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.21.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.21.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.21.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.21.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.21.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.21.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.21.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.21.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.21.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.21.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.21.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.21.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.21.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.21.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.21.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.21.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.21.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.21.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.21.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.22.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.22.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.22.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.22.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.22.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.22.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.22.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.22.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.22.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.22.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.22.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.22.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.22.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.22.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.22.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.22.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.22.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.22.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.22.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.22.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.22.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.22.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.22.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.22.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.22.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.22.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.22.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.22.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.22.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.22.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.22.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.22.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.22.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.22.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.22.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.22.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.22.4/Makefile b/linux/ecosystem/atlassian/jira/8/8.22.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.4/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.22.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.22.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.22.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.22.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.22.4/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.22.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.22.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.22.5/Makefile b/linux/ecosystem/atlassian/jira/8/8.22.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.5/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.22.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.22.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.22.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.22.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.22.5/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.22.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.22.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.22.6/Makefile b/linux/ecosystem/atlassian/jira/8/8.22.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.6/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.22.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.22.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.22.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.22.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.22.6/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.22.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.22.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.22.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.3.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.3.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.3.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.3.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.3.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.3.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.3.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.3.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.3.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.3.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.3.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.3.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.3.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.3.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.3.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.3.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.3.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.3.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.3.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.3.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.3.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.3.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.3.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.3.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.3.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.3.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.3.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.3.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.3.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.3.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.3.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.3.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.3.4/Makefile b/linux/ecosystem/atlassian/jira/8/8.3.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.4/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.3.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.3.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.3.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.3.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.3.4/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.3.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.3.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.3.5/Makefile b/linux/ecosystem/atlassian/jira/8/8.3.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.5/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.3.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.3.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.3.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.3.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.3.5/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.3.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.3.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.3.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.4.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.4.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.4.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.4.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.4.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.4.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.4.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.4.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.4.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.4.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.4.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.4.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.4.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.4.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.4.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.4.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.4.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.4.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.4.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.4.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.4.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.4.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.4.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.4.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.4.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.4.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.4.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.4.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.4.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.4.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.4.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.4.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.4.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.4.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.4.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.4.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.4.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.4.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.4.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.4.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.4.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.4.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.4.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.4.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.10/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.10/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.10/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.10/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.10/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.11/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.11/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.11/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.11/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.11/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.12/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.12/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.12/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.12/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.12/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.13/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.13/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.13/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.13/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.13/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.13/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.13/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.14/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.14/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.14/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.14/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.14/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.14/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.14/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.15/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.15/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.15/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.15/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.15/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.15/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.15/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.16/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.16/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.16/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.16/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.16/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.17/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.17/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.17/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.17/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.17/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.18/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.18/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.18/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.18/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.18/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.19/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.19/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.19/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.19/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.19/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.2/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.2/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.2/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.3/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.3/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.3/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.4/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.4/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.4/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.5/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.5/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.5/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.6/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.6/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.6/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.7/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.7/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.7/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.8/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.8/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.8/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.8/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.8/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.5.9/Makefile b/linux/ecosystem/atlassian/jira/8/8.5.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.9/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.5.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.5.9/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.5.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.5.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.5.9/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.5.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.5.9/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.5.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.6.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.6.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.6.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.6.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.6.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.6.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.6.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.6.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.6.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.6.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.6.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.6.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.6.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.6.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.6.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.6.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.6.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.6.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.6.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.6.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.6.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.6.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.7.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.7.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.7.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.7.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.7.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.7.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.7.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.7.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.7.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.7.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.7.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.7.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.7.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.7.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.7.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.7.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.7.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.7.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.7.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.7.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.7.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.7.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.8.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.8.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.8.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.8.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.8.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.8.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.8.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.8.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.8.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.8.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.8.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.8.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.8.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.8.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.8.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.8.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.8.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.8.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.8.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.8.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.8.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.8.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.9.0/Makefile b/linux/ecosystem/atlassian/jira/8/8.9.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.9.0/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.9.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.9.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.9.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.9.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.9.0/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.9.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.9.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.9.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/8/8.9.1/Makefile b/linux/ecosystem/atlassian/jira/8/8.9.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/8/8.9.1/Makefile +++ b/linux/ecosystem/atlassian/jira/8/8.9.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/8/8.9.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/8/8.9.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/8/8.9.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/8/8.9.1/requirements.txt b/linux/ecosystem/atlassian/jira/8/8.9.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/8/8.9.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/8/8.9.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.0.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.0.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.0.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.0.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.0.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.0.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.0.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.0.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.0.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.0.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.0.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.1.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.1.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.1.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.1.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.1.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.1.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.1.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.1.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.1.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.1.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.1.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.1.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.1.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.1.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.1.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.1.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.1.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.1.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.1.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.1.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.1.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.1.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.10.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.10.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.10.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.10.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.10.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.10.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.10.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.10.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.10.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.10.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.10.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.10.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.10.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.10.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.10.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.10.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.10.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.10.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.10.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.10.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.10.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.10.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.10.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.10.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.10.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.10.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.10.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.10.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.10.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.10.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.10.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.10.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.10.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.11.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.11.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.11.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.11.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.11.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.11.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.11.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.11.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.11.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.11.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.11.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.11.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.11.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.11.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.11.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.11.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.11.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.11.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.11.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.11.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.11.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.11.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.11.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.11.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.11.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.11.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.11.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.11.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.11.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.11.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.11.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.11.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.11.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.11.3/Makefile b/linux/ecosystem/atlassian/jira/9/9.11.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.11.3/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.11.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.11.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.11.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.11.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.11.3/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.11.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.11.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.11.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.12.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.12.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.12.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.12.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.12.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.12.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.12.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.12.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.12.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.12.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.12.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.12.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.12.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.12.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.12.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.12.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.12.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.12.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.12.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.12.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.12.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.12.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.12.12/Makefile b/linux/ecosystem/atlassian/jira/9/9.12.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.12.12/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.12.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.12.12/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.12.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.12.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.12.12/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.12.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.12.12/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.12.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.12.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.12.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.12.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.12.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.12.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.12.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.12.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.12.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.12.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.12.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.12.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.14.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.14.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.14.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.14.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.14.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.14.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.14.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.14.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.14.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.14.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.14.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.16.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.16.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.16.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.16.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.16.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.16.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.16.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.16.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.16.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.16.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.16.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.17.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.17.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.17.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.17.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.17.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.17.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.17.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.17.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.17.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.17.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.17.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.2.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.2.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.2.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.2.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.2.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.2.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.2.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.2.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.2.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.2.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.2.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.2.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.2.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.2.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.2.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.2.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.2.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.2.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.2.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.2.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.2.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.2.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.3.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.3.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.3.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.3.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.3.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.3.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.3.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.3.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.3.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.3.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.3.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.3.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.3.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.3.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.3.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.3.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.3.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.3.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.3.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.3.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.3.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.3.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.3.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.3.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.3.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.3.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.3.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.3.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.3.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.3.3/Makefile b/linux/ecosystem/atlassian/jira/9/9.3.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.3.3/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.3.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.3.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.3.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.3.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.3.3/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.3.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.3.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.3.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.4.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.4.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.4.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.4.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.4.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.4.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.4.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.4.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.4.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.4.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.4.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.4.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.4.10/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.10/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.4.10/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.4.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.4.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.4.10/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.10/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.4.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.4.11/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.11/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.4.11/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.4.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.4.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.4.11/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.11/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.4.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.4.12/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.12/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.4.12/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.4.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.4.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.4.12/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.12/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.4.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.4.14/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.14/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.14/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.14/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.4.14/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.4.14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.4.14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.4.14/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.14/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.4.14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.4.15/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.15/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.15/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.15/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.4.15/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.4.15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.4.15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.4.15/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.15/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.4.15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.4.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.4.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.4.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.4.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.4.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.4.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.4.3/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.3/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.4.3/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.4.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.4.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.4.3/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.3/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.4.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.4.4/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.4/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.4.4/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.4.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.4.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.4.4/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.4/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.4.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.4.5/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.5/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.4.5/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.4.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.4.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.4.5/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.5/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.4.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.4.6/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.6/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.4.6/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.4.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.4.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.4.6/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.6/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.4.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.4.7/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.7/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.4.7/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.4.7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.4.7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.4.7/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.7/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.4.7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.4.8/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.8/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.4.8/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.4.8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.4.8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.4.8/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.8/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.4.8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.4.9/Makefile b/linux/ecosystem/atlassian/jira/9/9.4.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.9/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.4.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.4.9/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.4.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.4.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.4.9/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.4.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.4.9/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.4.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.5.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.5.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.5.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.5.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.5.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.5.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.5.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.5.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.5.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.5.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.5.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.5.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.5.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.5.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.5.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.5.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.5.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.5.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.5.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.5.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.5.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.5.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.6.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.6.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.6.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.6.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.6.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.6.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.6.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.6.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.6.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.6.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.6.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.7.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.7.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.7.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.7.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.7.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.7.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.7.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.7.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.7.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.7.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.7.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.7.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.7.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.7.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.7.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.7.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.7.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.7.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.7.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.7.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.7.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.7.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.7.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.7.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.7.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.7.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.7.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.7.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.7.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.7.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.7.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.7.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.7.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.8.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.8.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.8.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.8.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.8.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.8.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.8.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.8.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.8.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.8.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.8.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.8.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.8.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.8.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.8.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.8.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.8.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.8.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.8.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.8.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.8.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.8.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.8.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.8.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.8.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.8.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.8.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.8.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.8.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.8.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.8.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.8.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.8.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.9.0/Makefile b/linux/ecosystem/atlassian/jira/9/9.9.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.9.0/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.9.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.9.0/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.9.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.9.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.9.0/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.9.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.9.0/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.9.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.9.1/Makefile b/linux/ecosystem/atlassian/jira/9/9.9.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.9.1/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.9.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.9.1/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.9.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.9.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.9.1/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.9.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.9.1/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.9.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/9/9.9.2/Makefile b/linux/ecosystem/atlassian/jira/9/9.9.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/9/9.9.2/Makefile +++ b/linux/ecosystem/atlassian/jira/9/9.9.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/9/9.9.2/kaniko-build.py b/linux/ecosystem/atlassian/jira/9/9.9.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/9/9.9.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/9/9.9.2/requirements.txt b/linux/ecosystem/atlassian/jira/9/9.9.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/9/9.9.2/requirements.txt +++ b/linux/ecosystem/atlassian/jira/9/9.9.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/atlassian/jira/latest/Makefile b/linux/ecosystem/atlassian/jira/latest/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/atlassian/jira/latest/Makefile +++ b/linux/ecosystem/atlassian/jira/latest/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/atlassian/jira/latest/kaniko-build.py b/linux/ecosystem/atlassian/jira/latest/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/atlassian/jira/latest/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/atlassian/jira/latest/requirements.txt b/linux/ecosystem/atlassian/jira/latest/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/atlassian/jira/latest/requirements.txt +++ b/linux/ecosystem/atlassian/jira/latest/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/cassandra/3.11/Makefile b/linux/ecosystem/cassandra/3.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/cassandra/3.11/Makefile +++ b/linux/ecosystem/cassandra/3.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/cassandra/3.11/kaniko-build.py b/linux/ecosystem/cassandra/3.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/cassandra/3.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/cassandra/3.11/requirements.txt b/linux/ecosystem/cassandra/3.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/cassandra/3.11/requirements.txt +++ b/linux/ecosystem/cassandra/3.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/electron-release-server/Makefile b/linux/ecosystem/electron-release-server/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/electron-release-server/Makefile +++ b/linux/ecosystem/electron-release-server/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/electron-release-server/kaniko-build.py b/linux/ecosystem/electron-release-server/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/electron-release-server/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/electron-release-server/requirements.txt b/linux/ecosystem/electron-release-server/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/electron-release-server/requirements.txt +++ b/linux/ecosystem/electron-release-server/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/develop/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/develop/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/develop/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/develop/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/develop/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/develop/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/develop/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/develop/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/develop/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/develop/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/develop/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk22/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/jdk8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/main/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/main/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/main/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/main/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/main/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/python3.13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/slim/Makefile b/linux/ecosystem/epicmorg/astra/1.7-alse/slim/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/slim/Makefile +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/slim/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/slim/kaniko-build.py b/linux/ecosystem/epicmorg/astra/1.7-alse/slim/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/slim/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/astra/1.7-alse/slim/requirements.txt b/linux/ecosystem/epicmorg/astra/1.7-alse/slim/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/astra/1.7-alse/slim/requirements.txt +++ b/linux/ecosystem/epicmorg/astra/1.7-alse/slim/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/develop/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/develop/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/develop/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/develop/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/develop/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/develop/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/develop/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/develop/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/develop/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/develop/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/develop/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk22/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/jdk8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/main/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/main/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/main/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/main/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/main/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/slim/Makefile b/linux/ecosystem/epicmorg/debian/06-squeeze/slim/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/slim/Makefile +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/slim/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/slim/kaniko-build.py b/linux/ecosystem/epicmorg/debian/06-squeeze/slim/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/slim/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/06-squeeze/slim/requirements.txt b/linux/ecosystem/epicmorg/debian/06-squeeze/slim/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/06-squeeze/slim/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/06-squeeze/slim/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/develop/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/develop/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/develop/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/develop/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/develop/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/develop/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/develop/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/develop/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/develop/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/develop/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/develop/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk22/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/jdk8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/main/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/main/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/main/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/main/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/main/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/slim/Makefile b/linux/ecosystem/epicmorg/debian/07-wheezy/slim/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/slim/Makefile +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/slim/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/slim/kaniko-build.py b/linux/ecosystem/epicmorg/debian/07-wheezy/slim/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/slim/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/07-wheezy/slim/requirements.txt b/linux/ecosystem/epicmorg/debian/07-wheezy/slim/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/07-wheezy/slim/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/07-wheezy/slim/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/develop/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/develop/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/develop/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/develop/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/develop/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/develop/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/08-jessie/develop/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/develop/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/develop/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/develop/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/08-jessie/develop/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk22/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/08-jessie/jdk8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/main/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/main/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/main/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/08-jessie/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/main/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/main/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/08-jessie/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/slim/Makefile b/linux/ecosystem/epicmorg/debian/08-jessie/slim/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/slim/Makefile +++ b/linux/ecosystem/epicmorg/debian/08-jessie/slim/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/slim/kaniko-build.py b/linux/ecosystem/epicmorg/debian/08-jessie/slim/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/08-jessie/slim/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/08-jessie/slim/requirements.txt b/linux/ecosystem/epicmorg/debian/08-jessie/slim/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/08-jessie/slim/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/08-jessie/slim/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/develop/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/develop/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/develop/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/develop/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/develop/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/develop/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/09-stretch/develop/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/develop/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/develop/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/develop/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/09-stretch/develop/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk22/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/09-stretch/jdk8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/main/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/main/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/main/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/09-stretch/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/main/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/main/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/09-stretch/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/slim/Makefile b/linux/ecosystem/epicmorg/debian/09-stretch/slim/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/slim/Makefile +++ b/linux/ecosystem/epicmorg/debian/09-stretch/slim/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/slim/kaniko-build.py b/linux/ecosystem/epicmorg/debian/09-stretch/slim/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/09-stretch/slim/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/09-stretch/slim/requirements.txt b/linux/ecosystem/epicmorg/debian/09-stretch/slim/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/09-stretch/slim/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/09-stretch/slim/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/10-buster/develop/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/develop/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/develop/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/develop/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/10-buster/develop/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/develop/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/10-buster/develop/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/10-buster/develop/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/develop/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/develop/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/10-buster/develop/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk11/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk11/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk11/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk11/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk16/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk16/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk16/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk16/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk17/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk17/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk17/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk17/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk18/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk18/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk18/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk18/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk19/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk19/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk19/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk19/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk19/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk20/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk20/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk20/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk20/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk20/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk20/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk21/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk21/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk21/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk21/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk22/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk22/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk22/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk22/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk22/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk22/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk22/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk22/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk22/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk22/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk6/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk6/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk6/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk6/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk7/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk7/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk7/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk7/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk8/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/jdk8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk8/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/jdk8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/10-buster/jdk8/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/jdk8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/jdk8/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/10-buster/jdk8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/10-buster/main/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/main/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/10-buster/main/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/10-buster/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/10-buster/main/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/main/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/10-buster/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/10-buster/slim/Makefile b/linux/ecosystem/epicmorg/debian/10-buster/slim/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/slim/Makefile +++ b/linux/ecosystem/epicmorg/debian/10-buster/slim/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/10-buster/slim/kaniko-build.py b/linux/ecosystem/epicmorg/debian/10-buster/slim/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/10-buster/slim/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/10-buster/slim/requirements.txt b/linux/ecosystem/epicmorg/debian/10-buster/slim/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/10-buster/slim/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/10-buster/slim/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/develop/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/develop/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/develop/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/develop/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/develop/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/develop/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/develop/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/develop/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/develop/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/develop/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/develop/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk22/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/jdk8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/main/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/main/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/main/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/main/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/main/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/slim/Makefile b/linux/ecosystem/epicmorg/debian/11-bullseye/slim/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/slim/Makefile +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/slim/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/slim/kaniko-build.py b/linux/ecosystem/epicmorg/debian/11-bullseye/slim/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/slim/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/11-bullseye/slim/requirements.txt b/linux/ecosystem/epicmorg/debian/11-bullseye/slim/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/11-bullseye/slim/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/11-bullseye/slim/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/develop/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/develop/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/develop/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/develop/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/develop/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/develop/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/develop/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/develop/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/develop/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/develop/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/develop/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk22/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/jdk8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/main/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/main/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/main/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/main/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/main/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/slim/Makefile b/linux/ecosystem/epicmorg/debian/12-bookworm/slim/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/slim/Makefile +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/slim/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/slim/kaniko-build.py b/linux/ecosystem/epicmorg/debian/12-bookworm/slim/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/slim/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/epicmorg/debian/12-bookworm/slim/requirements.txt b/linux/ecosystem/epicmorg/debian/12-bookworm/slim/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/epicmorg/debian/12-bookworm/slim/requirements.txt +++ b/linux/ecosystem/epicmorg/debian/12-bookworm/slim/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/Makefile b/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/Makefile +++ b/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/kaniko-build.py b/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/requirements.txt b/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/requirements.txt +++ b/linux/ecosystem/gitlab/runner/amxx-sdk/1.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/Makefile b/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/Makefile +++ b/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/kaniko-build.py b/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/requirements.txt b/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/requirements.txt +++ b/linux/ecosystem/gitlab/runner/amxx-sdk/1.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/android-sdk/jdk11/Makefile b/linux/ecosystem/gitlab/runner/android-sdk/jdk11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/android-sdk/jdk11/Makefile +++ b/linux/ecosystem/gitlab/runner/android-sdk/jdk11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/android-sdk/jdk11/kaniko-build.py b/linux/ecosystem/gitlab/runner/android-sdk/jdk11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/android-sdk/jdk11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/android-sdk/jdk11/requirements.txt b/linux/ecosystem/gitlab/runner/android-sdk/jdk11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/android-sdk/jdk11/requirements.txt +++ b/linux/ecosystem/gitlab/runner/android-sdk/jdk11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/android-sdk/jdk17/Makefile b/linux/ecosystem/gitlab/runner/android-sdk/jdk17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/android-sdk/jdk17/Makefile +++ b/linux/ecosystem/gitlab/runner/android-sdk/jdk17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/android-sdk/jdk17/kaniko-build.py b/linux/ecosystem/gitlab/runner/android-sdk/jdk17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/android-sdk/jdk17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/android-sdk/jdk17/requirements.txt b/linux/ecosystem/gitlab/runner/android-sdk/jdk17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/android-sdk/jdk17/requirements.txt +++ b/linux/ecosystem/gitlab/runner/android-sdk/jdk17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/android-sdk/jdk8/Makefile b/linux/ecosystem/gitlab/runner/android-sdk/jdk8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/android-sdk/jdk8/Makefile +++ b/linux/ecosystem/gitlab/runner/android-sdk/jdk8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/android-sdk/jdk8/kaniko-build.py b/linux/ecosystem/gitlab/runner/android-sdk/jdk8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/android-sdk/jdk8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/android-sdk/jdk8/requirements.txt b/linux/ecosystem/gitlab/runner/android-sdk/jdk8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/android-sdk/jdk8/requirements.txt +++ b/linux/ecosystem/gitlab/runner/android-sdk/jdk8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/atlassian-sdk/Makefile b/linux/ecosystem/gitlab/runner/atlassian-sdk/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/atlassian-sdk/Makefile +++ b/linux/ecosystem/gitlab/runner/atlassian-sdk/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/atlassian-sdk/kaniko-build.py b/linux/ecosystem/gitlab/runner/atlassian-sdk/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/atlassian-sdk/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/atlassian-sdk/requirements.txt b/linux/ecosystem/gitlab/runner/atlassian-sdk/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/atlassian-sdk/requirements.txt +++ b/linux/ecosystem/gitlab/runner/atlassian-sdk/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/dotnet-sdk/Makefile b/linux/ecosystem/gitlab/runner/dotnet-sdk/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/dotnet-sdk/Makefile +++ b/linux/ecosystem/gitlab/runner/dotnet-sdk/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/dotnet-sdk/kaniko-build.py b/linux/ecosystem/gitlab/runner/dotnet-sdk/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/dotnet-sdk/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/dotnet-sdk/requirements.txt b/linux/ecosystem/gitlab/runner/dotnet-sdk/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/dotnet-sdk/requirements.txt +++ b/linux/ecosystem/gitlab/runner/dotnet-sdk/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/latest/Makefile b/linux/ecosystem/gitlab/runner/latest/Makefile index 102f672d0..9fa705b74 100644 --- a/linux/ecosystem/gitlab/runner/latest/Makefile +++ b/linux/ecosystem/gitlab/runner/latest/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/latest/kaniko-build.py b/linux/ecosystem/gitlab/runner/latest/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/latest/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/latest/requirements.txt b/linux/ecosystem/gitlab/runner/latest/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/latest/requirements.txt +++ b/linux/ecosystem/gitlab/runner/latest/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node0.12/Makefile b/linux/ecosystem/gitlab/runner/node0.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node0.12/Makefile +++ b/linux/ecosystem/gitlab/runner/node0.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node0.12/kaniko-build.py b/linux/ecosystem/gitlab/runner/node0.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node0.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node0.12/requirements.txt b/linux/ecosystem/gitlab/runner/node0.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node0.12/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node0.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node10/Makefile b/linux/ecosystem/gitlab/runner/node10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node10/Makefile +++ b/linux/ecosystem/gitlab/runner/node10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node10/kaniko-build.py b/linux/ecosystem/gitlab/runner/node10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node10/requirements.txt b/linux/ecosystem/gitlab/runner/node10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node10/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node11/Makefile b/linux/ecosystem/gitlab/runner/node11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node11/Makefile +++ b/linux/ecosystem/gitlab/runner/node11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node11/kaniko-build.py b/linux/ecosystem/gitlab/runner/node11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node11/requirements.txt b/linux/ecosystem/gitlab/runner/node11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node11/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node12/Makefile b/linux/ecosystem/gitlab/runner/node12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node12/Makefile +++ b/linux/ecosystem/gitlab/runner/node12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node12/kaniko-build.py b/linux/ecosystem/gitlab/runner/node12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node12/requirements.txt b/linux/ecosystem/gitlab/runner/node12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node12/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node13/Makefile b/linux/ecosystem/gitlab/runner/node13/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node13/Makefile +++ b/linux/ecosystem/gitlab/runner/node13/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node13/kaniko-build.py b/linux/ecosystem/gitlab/runner/node13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node13/requirements.txt b/linux/ecosystem/gitlab/runner/node13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node13/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node14/Makefile b/linux/ecosystem/gitlab/runner/node14/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node14/Makefile +++ b/linux/ecosystem/gitlab/runner/node14/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node14/kaniko-build.py b/linux/ecosystem/gitlab/runner/node14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node14/requirements.txt b/linux/ecosystem/gitlab/runner/node14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node14/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node15/Makefile b/linux/ecosystem/gitlab/runner/node15/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node15/Makefile +++ b/linux/ecosystem/gitlab/runner/node15/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node15/kaniko-build.py b/linux/ecosystem/gitlab/runner/node15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node15/requirements.txt b/linux/ecosystem/gitlab/runner/node15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node15/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node16/Makefile b/linux/ecosystem/gitlab/runner/node16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node16/Makefile +++ b/linux/ecosystem/gitlab/runner/node16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node16/kaniko-build.py b/linux/ecosystem/gitlab/runner/node16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node16/requirements.txt b/linux/ecosystem/gitlab/runner/node16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node16/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node17/Makefile b/linux/ecosystem/gitlab/runner/node17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node17/Makefile +++ b/linux/ecosystem/gitlab/runner/node17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node17/kaniko-build.py b/linux/ecosystem/gitlab/runner/node17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node17/requirements.txt b/linux/ecosystem/gitlab/runner/node17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node17/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node18/Makefile b/linux/ecosystem/gitlab/runner/node18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node18/Makefile +++ b/linux/ecosystem/gitlab/runner/node18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node18/kaniko-build.py b/linux/ecosystem/gitlab/runner/node18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node18/requirements.txt b/linux/ecosystem/gitlab/runner/node18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node18/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node19/Makefile b/linux/ecosystem/gitlab/runner/node19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node19/Makefile +++ b/linux/ecosystem/gitlab/runner/node19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node19/kaniko-build.py b/linux/ecosystem/gitlab/runner/node19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node19/requirements.txt b/linux/ecosystem/gitlab/runner/node19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node19/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node20/Makefile b/linux/ecosystem/gitlab/runner/node20/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node20/Makefile +++ b/linux/ecosystem/gitlab/runner/node20/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node20/kaniko-build.py b/linux/ecosystem/gitlab/runner/node20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node20/requirements.txt b/linux/ecosystem/gitlab/runner/node20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node20/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node21/Makefile b/linux/ecosystem/gitlab/runner/node21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node21/Makefile +++ b/linux/ecosystem/gitlab/runner/node21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node21/kaniko-build.py b/linux/ecosystem/gitlab/runner/node21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node21/requirements.txt b/linux/ecosystem/gitlab/runner/node21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node21/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node22/Makefile b/linux/ecosystem/gitlab/runner/node22/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node22/Makefile +++ b/linux/ecosystem/gitlab/runner/node22/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node22/kaniko-build.py b/linux/ecosystem/gitlab/runner/node22/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node22/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node22/requirements.txt b/linux/ecosystem/gitlab/runner/node22/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node22/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node22/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node4/Makefile b/linux/ecosystem/gitlab/runner/node4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node4/Makefile +++ b/linux/ecosystem/gitlab/runner/node4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node4/kaniko-build.py b/linux/ecosystem/gitlab/runner/node4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node4/requirements.txt b/linux/ecosystem/gitlab/runner/node4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node4/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node5/Makefile b/linux/ecosystem/gitlab/runner/node5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node5/Makefile +++ b/linux/ecosystem/gitlab/runner/node5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node5/kaniko-build.py b/linux/ecosystem/gitlab/runner/node5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node5/requirements.txt b/linux/ecosystem/gitlab/runner/node5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node5/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node6/Makefile b/linux/ecosystem/gitlab/runner/node6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node6/Makefile +++ b/linux/ecosystem/gitlab/runner/node6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node6/kaniko-build.py b/linux/ecosystem/gitlab/runner/node6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node6/requirements.txt b/linux/ecosystem/gitlab/runner/node6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node6/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node7/Makefile b/linux/ecosystem/gitlab/runner/node7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node7/Makefile +++ b/linux/ecosystem/gitlab/runner/node7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node7/kaniko-build.py b/linux/ecosystem/gitlab/runner/node7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node7/requirements.txt b/linux/ecosystem/gitlab/runner/node7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node7/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node8/Makefile b/linux/ecosystem/gitlab/runner/node8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node8/Makefile +++ b/linux/ecosystem/gitlab/runner/node8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node8/kaniko-build.py b/linux/ecosystem/gitlab/runner/node8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node8/requirements.txt b/linux/ecosystem/gitlab/runner/node8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node8/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/node9/Makefile b/linux/ecosystem/gitlab/runner/node9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/node9/Makefile +++ b/linux/ecosystem/gitlab/runner/node9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/node9/kaniko-build.py b/linux/ecosystem/gitlab/runner/node9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/node9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/node9/requirements.txt b/linux/ecosystem/gitlab/runner/node9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/node9/requirements.txt +++ b/linux/ecosystem/gitlab/runner/node9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/php7.2/Makefile b/linux/ecosystem/gitlab/runner/php7.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/php7.2/Makefile +++ b/linux/ecosystem/gitlab/runner/php7.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/php7.2/kaniko-build.py b/linux/ecosystem/gitlab/runner/php7.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/php7.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/php7.2/requirements.txt b/linux/ecosystem/gitlab/runner/php7.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/php7.2/requirements.txt +++ b/linux/ecosystem/gitlab/runner/php7.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/php7.3/Makefile b/linux/ecosystem/gitlab/runner/php7.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/php7.3/Makefile +++ b/linux/ecosystem/gitlab/runner/php7.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/php7.3/kaniko-build.py b/linux/ecosystem/gitlab/runner/php7.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/php7.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/php7.3/requirements.txt b/linux/ecosystem/gitlab/runner/php7.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/php7.3/requirements.txt +++ b/linux/ecosystem/gitlab/runner/php7.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/php7.4/Makefile b/linux/ecosystem/gitlab/runner/php7.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/php7.4/Makefile +++ b/linux/ecosystem/gitlab/runner/php7.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/php7.4/kaniko-build.py b/linux/ecosystem/gitlab/runner/php7.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/php7.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/php7.4/requirements.txt b/linux/ecosystem/gitlab/runner/php7.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/php7.4/requirements.txt +++ b/linux/ecosystem/gitlab/runner/php7.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/php8.0/Makefile b/linux/ecosystem/gitlab/runner/php8.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/php8.0/Makefile +++ b/linux/ecosystem/gitlab/runner/php8.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/php8.0/kaniko-build.py b/linux/ecosystem/gitlab/runner/php8.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/php8.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/php8.0/requirements.txt b/linux/ecosystem/gitlab/runner/php8.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/php8.0/requirements.txt +++ b/linux/ecosystem/gitlab/runner/php8.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/php8.1/Makefile b/linux/ecosystem/gitlab/runner/php8.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/php8.1/Makefile +++ b/linux/ecosystem/gitlab/runner/php8.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/php8.1/kaniko-build.py b/linux/ecosystem/gitlab/runner/php8.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/php8.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/php8.1/requirements.txt b/linux/ecosystem/gitlab/runner/php8.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/php8.1/requirements.txt +++ b/linux/ecosystem/gitlab/runner/php8.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/php8.2/Makefile b/linux/ecosystem/gitlab/runner/php8.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/php8.2/Makefile +++ b/linux/ecosystem/gitlab/runner/php8.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/php8.2/kaniko-build.py b/linux/ecosystem/gitlab/runner/php8.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/php8.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/php8.2/requirements.txt b/linux/ecosystem/gitlab/runner/php8.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/php8.2/requirements.txt +++ b/linux/ecosystem/gitlab/runner/php8.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/php8.3/Makefile b/linux/ecosystem/gitlab/runner/php8.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/php8.3/Makefile +++ b/linux/ecosystem/gitlab/runner/php8.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/php8.3/kaniko-build.py b/linux/ecosystem/gitlab/runner/php8.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/php8.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/php8.3/requirements.txt b/linux/ecosystem/gitlab/runner/php8.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/php8.3/requirements.txt +++ b/linux/ecosystem/gitlab/runner/php8.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/gitlab/runner/steam-sdk/Makefile b/linux/ecosystem/gitlab/runner/steam-sdk/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/gitlab/runner/steam-sdk/Makefile +++ b/linux/ecosystem/gitlab/runner/steam-sdk/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/gitlab/runner/steam-sdk/kaniko-build.py b/linux/ecosystem/gitlab/runner/steam-sdk/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/gitlab/runner/steam-sdk/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/gitlab/runner/steam-sdk/requirements.txt b/linux/ecosystem/gitlab/runner/steam-sdk/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/gitlab/runner/steam-sdk/requirements.txt +++ b/linux/ecosystem/gitlab/runner/steam-sdk/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/monero/monerod/Makefile b/linux/ecosystem/monero/monerod/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/monero/monerod/Makefile +++ b/linux/ecosystem/monero/monerod/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/monero/monerod/kaniko-build.py b/linux/ecosystem/monero/monerod/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/monero/monerod/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/monero/monerod/requirements.txt b/linux/ecosystem/monero/monerod/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/monero/monerod/requirements.txt +++ b/linux/ecosystem/monero/monerod/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/monero/p2pool/Makefile b/linux/ecosystem/monero/p2pool/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/monero/p2pool/Makefile +++ b/linux/ecosystem/monero/p2pool/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/monero/p2pool/kaniko-build.py b/linux/ecosystem/monero/p2pool/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/monero/p2pool/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/monero/p2pool/requirements.txt b/linux/ecosystem/monero/p2pool/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/monero/p2pool/requirements.txt +++ b/linux/ecosystem/monero/p2pool/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.14.2/main/Makefile b/linux/ecosystem/nginx/1.14.2/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.14.2/main/Makefile +++ b/linux/ecosystem/nginx/1.14.2/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.14.2/main/kaniko-build.py b/linux/ecosystem/nginx/1.14.2/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.14.2/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.14.2/main/requirements.txt b/linux/ecosystem/nginx/1.14.2/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.14.2/main/requirements.txt +++ b/linux/ecosystem/nginx/1.14.2/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.14.2/php/Makefile b/linux/ecosystem/nginx/1.14.2/php/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.14.2/php/Makefile +++ b/linux/ecosystem/nginx/1.14.2/php/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.14.2/php/kaniko-build.py b/linux/ecosystem/nginx/1.14.2/php/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.14.2/php/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.14.2/php/requirements.txt b/linux/ecosystem/nginx/1.14.2/php/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.14.2/php/requirements.txt +++ b/linux/ecosystem/nginx/1.14.2/php/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.14.2/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.14.2/rtmp-hls/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.14.2/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.14.2/rtmp-hls/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.14.2/rtmp-hls/kaniko-build.py b/linux/ecosystem/nginx/1.14.2/rtmp-hls/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.14.2/rtmp-hls/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.14.2/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.14.2/rtmp-hls/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.14.2/rtmp-hls/requirements.txt +++ b/linux/ecosystem/nginx/1.14.2/rtmp-hls/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.15.12/main/Makefile b/linux/ecosystem/nginx/1.15.12/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.15.12/main/Makefile +++ b/linux/ecosystem/nginx/1.15.12/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.15.12/main/kaniko-build.py b/linux/ecosystem/nginx/1.15.12/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.15.12/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.15.12/main/requirements.txt b/linux/ecosystem/nginx/1.15.12/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.15.12/main/requirements.txt +++ b/linux/ecosystem/nginx/1.15.12/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.15.12/php/Makefile b/linux/ecosystem/nginx/1.15.12/php/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.15.12/php/Makefile +++ b/linux/ecosystem/nginx/1.15.12/php/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.15.12/php/kaniko-build.py b/linux/ecosystem/nginx/1.15.12/php/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.15.12/php/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.15.12/php/requirements.txt b/linux/ecosystem/nginx/1.15.12/php/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.15.12/php/requirements.txt +++ b/linux/ecosystem/nginx/1.15.12/php/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.15.12/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.15.12/rtmp-hls/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.15.12/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.15.12/rtmp-hls/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.15.12/rtmp-hls/kaniko-build.py b/linux/ecosystem/nginx/1.15.12/rtmp-hls/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.15.12/rtmp-hls/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.15.12/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.15.12/rtmp-hls/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.15.12/rtmp-hls/requirements.txt +++ b/linux/ecosystem/nginx/1.15.12/rtmp-hls/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.16.1/main/Makefile b/linux/ecosystem/nginx/1.16.1/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.16.1/main/Makefile +++ b/linux/ecosystem/nginx/1.16.1/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.16.1/main/kaniko-build.py b/linux/ecosystem/nginx/1.16.1/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.16.1/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.16.1/main/requirements.txt b/linux/ecosystem/nginx/1.16.1/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.16.1/main/requirements.txt +++ b/linux/ecosystem/nginx/1.16.1/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.16.1/php/Makefile b/linux/ecosystem/nginx/1.16.1/php/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.16.1/php/Makefile +++ b/linux/ecosystem/nginx/1.16.1/php/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.16.1/php/kaniko-build.py b/linux/ecosystem/nginx/1.16.1/php/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.16.1/php/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.16.1/php/requirements.txt b/linux/ecosystem/nginx/1.16.1/php/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.16.1/php/requirements.txt +++ b/linux/ecosystem/nginx/1.16.1/php/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.16.1/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.16.1/rtmp-hls/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.16.1/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.16.1/rtmp-hls/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.16.1/rtmp-hls/kaniko-build.py b/linux/ecosystem/nginx/1.16.1/rtmp-hls/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.16.1/rtmp-hls/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.16.1/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.16.1/rtmp-hls/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.16.1/rtmp-hls/requirements.txt +++ b/linux/ecosystem/nginx/1.16.1/rtmp-hls/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.17.10/main/Makefile b/linux/ecosystem/nginx/1.17.10/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.17.10/main/Makefile +++ b/linux/ecosystem/nginx/1.17.10/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.17.10/main/kaniko-build.py b/linux/ecosystem/nginx/1.17.10/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.17.10/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.17.10/main/requirements.txt b/linux/ecosystem/nginx/1.17.10/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.17.10/main/requirements.txt +++ b/linux/ecosystem/nginx/1.17.10/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.17.10/php/Makefile b/linux/ecosystem/nginx/1.17.10/php/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.17.10/php/Makefile +++ b/linux/ecosystem/nginx/1.17.10/php/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.17.10/php/kaniko-build.py b/linux/ecosystem/nginx/1.17.10/php/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.17.10/php/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.17.10/php/requirements.txt b/linux/ecosystem/nginx/1.17.10/php/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.17.10/php/requirements.txt +++ b/linux/ecosystem/nginx/1.17.10/php/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.17.10/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.17.10/rtmp-hls/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.17.10/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.17.10/rtmp-hls/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.17.10/rtmp-hls/kaniko-build.py b/linux/ecosystem/nginx/1.17.10/rtmp-hls/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.17.10/rtmp-hls/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.17.10/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.17.10/rtmp-hls/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.17.10/rtmp-hls/requirements.txt +++ b/linux/ecosystem/nginx/1.17.10/rtmp-hls/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.18.0/main/Makefile b/linux/ecosystem/nginx/1.18.0/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.18.0/main/Makefile +++ b/linux/ecosystem/nginx/1.18.0/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.18.0/main/kaniko-build.py b/linux/ecosystem/nginx/1.18.0/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.18.0/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.18.0/main/requirements.txt b/linux/ecosystem/nginx/1.18.0/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.18.0/main/requirements.txt +++ b/linux/ecosystem/nginx/1.18.0/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.18.0/php/Makefile b/linux/ecosystem/nginx/1.18.0/php/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.18.0/php/Makefile +++ b/linux/ecosystem/nginx/1.18.0/php/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.18.0/php/kaniko-build.py b/linux/ecosystem/nginx/1.18.0/php/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.18.0/php/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.18.0/php/requirements.txt b/linux/ecosystem/nginx/1.18.0/php/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.18.0/php/requirements.txt +++ b/linux/ecosystem/nginx/1.18.0/php/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.18.0/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.18.0/rtmp-hls/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.18.0/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.18.0/rtmp-hls/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.18.0/rtmp-hls/kaniko-build.py b/linux/ecosystem/nginx/1.18.0/rtmp-hls/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.18.0/rtmp-hls/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.18.0/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.18.0/rtmp-hls/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.18.0/rtmp-hls/requirements.txt +++ b/linux/ecosystem/nginx/1.18.0/rtmp-hls/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.19.10/main/Makefile b/linux/ecosystem/nginx/1.19.10/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.19.10/main/Makefile +++ b/linux/ecosystem/nginx/1.19.10/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.19.10/main/kaniko-build.py b/linux/ecosystem/nginx/1.19.10/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.19.10/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.19.10/main/requirements.txt b/linux/ecosystem/nginx/1.19.10/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.19.10/main/requirements.txt +++ b/linux/ecosystem/nginx/1.19.10/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.19.10/php/Makefile b/linux/ecosystem/nginx/1.19.10/php/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.19.10/php/Makefile +++ b/linux/ecosystem/nginx/1.19.10/php/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.19.10/php/kaniko-build.py b/linux/ecosystem/nginx/1.19.10/php/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.19.10/php/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.19.10/php/requirements.txt b/linux/ecosystem/nginx/1.19.10/php/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.19.10/php/requirements.txt +++ b/linux/ecosystem/nginx/1.19.10/php/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.19.10/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.19.10/rtmp-hls/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.19.10/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.19.10/rtmp-hls/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.19.10/rtmp-hls/kaniko-build.py b/linux/ecosystem/nginx/1.19.10/rtmp-hls/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.19.10/rtmp-hls/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.19.10/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.19.10/rtmp-hls/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.19.10/rtmp-hls/requirements.txt +++ b/linux/ecosystem/nginx/1.19.10/rtmp-hls/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.20.1/main/Makefile b/linux/ecosystem/nginx/1.20.1/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.20.1/main/Makefile +++ b/linux/ecosystem/nginx/1.20.1/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.20.1/main/kaniko-build.py b/linux/ecosystem/nginx/1.20.1/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.20.1/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.20.1/main/requirements.txt b/linux/ecosystem/nginx/1.20.1/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.20.1/main/requirements.txt +++ b/linux/ecosystem/nginx/1.20.1/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.20.1/php/Makefile b/linux/ecosystem/nginx/1.20.1/php/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.20.1/php/Makefile +++ b/linux/ecosystem/nginx/1.20.1/php/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.20.1/php/kaniko-build.py b/linux/ecosystem/nginx/1.20.1/php/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.20.1/php/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.20.1/php/requirements.txt b/linux/ecosystem/nginx/1.20.1/php/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.20.1/php/requirements.txt +++ b/linux/ecosystem/nginx/1.20.1/php/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.20.1/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.20.1/rtmp-hls/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.20.1/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.20.1/rtmp-hls/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.20.1/rtmp-hls/kaniko-build.py b/linux/ecosystem/nginx/1.20.1/rtmp-hls/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.20.1/rtmp-hls/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.20.1/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.20.1/rtmp-hls/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.20.1/rtmp-hls/requirements.txt +++ b/linux/ecosystem/nginx/1.20.1/rtmp-hls/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.21.3/main/Makefile b/linux/ecosystem/nginx/1.21.3/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.21.3/main/Makefile +++ b/linux/ecosystem/nginx/1.21.3/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.21.3/main/kaniko-build.py b/linux/ecosystem/nginx/1.21.3/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.21.3/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.21.3/main/requirements.txt b/linux/ecosystem/nginx/1.21.3/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.21.3/main/requirements.txt +++ b/linux/ecosystem/nginx/1.21.3/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.21.3/php/Makefile b/linux/ecosystem/nginx/1.21.3/php/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.21.3/php/Makefile +++ b/linux/ecosystem/nginx/1.21.3/php/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.21.3/php/kaniko-build.py b/linux/ecosystem/nginx/1.21.3/php/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.21.3/php/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.21.3/php/requirements.txt b/linux/ecosystem/nginx/1.21.3/php/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.21.3/php/requirements.txt +++ b/linux/ecosystem/nginx/1.21.3/php/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.21.3/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.21.3/rtmp-hls/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.21.3/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.21.3/rtmp-hls/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.21.3/rtmp-hls/kaniko-build.py b/linux/ecosystem/nginx/1.21.3/rtmp-hls/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.21.3/rtmp-hls/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.21.3/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.21.3/rtmp-hls/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.21.3/rtmp-hls/requirements.txt +++ b/linux/ecosystem/nginx/1.21.3/rtmp-hls/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.21.6/main/Makefile b/linux/ecosystem/nginx/1.21.6/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.21.6/main/Makefile +++ b/linux/ecosystem/nginx/1.21.6/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.21.6/main/kaniko-build.py b/linux/ecosystem/nginx/1.21.6/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.21.6/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.21.6/main/requirements.txt b/linux/ecosystem/nginx/1.21.6/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.21.6/main/requirements.txt +++ b/linux/ecosystem/nginx/1.21.6/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.21.6/php/Makefile b/linux/ecosystem/nginx/1.21.6/php/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.21.6/php/Makefile +++ b/linux/ecosystem/nginx/1.21.6/php/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.21.6/php/kaniko-build.py b/linux/ecosystem/nginx/1.21.6/php/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.21.6/php/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.21.6/php/requirements.txt b/linux/ecosystem/nginx/1.21.6/php/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.21.6/php/requirements.txt +++ b/linux/ecosystem/nginx/1.21.6/php/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.21.6/rtmp-hls/Makefile b/linux/ecosystem/nginx/1.21.6/rtmp-hls/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.21.6/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/1.21.6/rtmp-hls/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.21.6/rtmp-hls/kaniko-build.py b/linux/ecosystem/nginx/1.21.6/rtmp-hls/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.21.6/rtmp-hls/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.21.6/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/1.21.6/rtmp-hls/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.21.6/rtmp-hls/requirements.txt +++ b/linux/ecosystem/nginx/1.21.6/rtmp-hls/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/1.27.0/main/Makefile b/linux/ecosystem/nginx/1.27.0/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/1.27.0/main/Makefile +++ b/linux/ecosystem/nginx/1.27.0/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/1.27.0/main/etc/nginx/nginx.conf b/linux/ecosystem/nginx/1.27.0/main/etc/nginx/nginx.conf index 18eef7a78..75dad302b 100644 --- a/linux/ecosystem/nginx/1.27.0/main/etc/nginx/nginx.conf +++ b/linux/ecosystem/nginx/1.27.0/main/etc/nginx/nginx.conf @@ -20,12 +20,17 @@ http { tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; - types_hash_max_size 2048; + types_hash_max_size 512; + types_hash_bucket_size 128; # server_tokens off; - # server_names_hash_bucket_size 64; + server_names_hash_max_size 512; + server_names_hash_bucket_size 128; # server_name_in_redirect off; + variables_hash_max_size 2048; + variables_hash_bucket_size 512; + include /etc/nginx/mime.types; default_type application/octet-stream; diff --git a/linux/ecosystem/nginx/1.27.0/main/kaniko-build.py b/linux/ecosystem/nginx/1.27.0/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/1.27.0/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/1.27.0/main/requirements.txt b/linux/ecosystem/nginx/1.27.0/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/1.27.0/main/requirements.txt +++ b/linux/ecosystem/nginx/1.27.0/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/latest/mainline/main/Makefile b/linux/ecosystem/nginx/latest/mainline/main/Makefile index 72aa38b1b..558bb3cb2 100644 --- a/linux/ecosystem/nginx/latest/mainline/main/Makefile +++ b/linux/ecosystem/nginx/latest/mainline/main/Makefile @@ -9,11 +9,11 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/latest/mainline/main/kaniko-build.py b/linux/ecosystem/nginx/latest/mainline/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/latest/mainline/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/latest/mainline/main/requirements.txt b/linux/ecosystem/nginx/latest/mainline/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/latest/mainline/main/requirements.txt +++ b/linux/ecosystem/nginx/latest/mainline/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/latest/mainline/php/Makefile b/linux/ecosystem/nginx/latest/mainline/php/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/latest/mainline/php/Makefile +++ b/linux/ecosystem/nginx/latest/mainline/php/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/latest/mainline/php/kaniko-build.py b/linux/ecosystem/nginx/latest/mainline/php/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/latest/mainline/php/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/latest/mainline/php/requirements.txt b/linux/ecosystem/nginx/latest/mainline/php/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/latest/mainline/php/requirements.txt +++ b/linux/ecosystem/nginx/latest/mainline/php/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/latest/mainline/rtmp-hls/Makefile b/linux/ecosystem/nginx/latest/mainline/rtmp-hls/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/latest/mainline/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/latest/mainline/rtmp-hls/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/latest/mainline/rtmp-hls/kaniko-build.py b/linux/ecosystem/nginx/latest/mainline/rtmp-hls/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/latest/mainline/rtmp-hls/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/latest/mainline/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/latest/mainline/rtmp-hls/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/latest/mainline/rtmp-hls/requirements.txt +++ b/linux/ecosystem/nginx/latest/mainline/rtmp-hls/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/latest/quic/main/Makefile b/linux/ecosystem/nginx/latest/quic/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/latest/quic/main/Makefile +++ b/linux/ecosystem/nginx/latest/quic/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/latest/quic/main/kaniko-build.py b/linux/ecosystem/nginx/latest/quic/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/latest/quic/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/latest/quic/main/requirements.txt b/linux/ecosystem/nginx/latest/quic/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/latest/quic/main/requirements.txt +++ b/linux/ecosystem/nginx/latest/quic/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/latest/quic/php/Makefile b/linux/ecosystem/nginx/latest/quic/php/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/latest/quic/php/Makefile +++ b/linux/ecosystem/nginx/latest/quic/php/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/latest/quic/php/kaniko-build.py b/linux/ecosystem/nginx/latest/quic/php/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/latest/quic/php/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/latest/quic/php/requirements.txt b/linux/ecosystem/nginx/latest/quic/php/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/latest/quic/php/requirements.txt +++ b/linux/ecosystem/nginx/latest/quic/php/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nginx/latest/quic/rtmp-hls/Makefile b/linux/ecosystem/nginx/latest/quic/rtmp-hls/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nginx/latest/quic/rtmp-hls/Makefile +++ b/linux/ecosystem/nginx/latest/quic/rtmp-hls/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nginx/latest/quic/rtmp-hls/kaniko-build.py b/linux/ecosystem/nginx/latest/quic/rtmp-hls/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nginx/latest/quic/rtmp-hls/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nginx/latest/quic/rtmp-hls/requirements.txt b/linux/ecosystem/nginx/latest/quic/rtmp-hls/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nginx/latest/quic/rtmp-hls/requirements.txt +++ b/linux/ecosystem/nginx/latest/quic/rtmp-hls/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/ninjam/latest/Makefile b/linux/ecosystem/ninjam/latest/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/ninjam/latest/Makefile +++ b/linux/ecosystem/ninjam/latest/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/ninjam/latest/kaniko-build.py b/linux/ecosystem/ninjam/latest/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/ninjam/latest/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/ninjam/latest/requirements.txt b/linux/ecosystem/ninjam/latest/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/ninjam/latest/requirements.txt +++ b/linux/ecosystem/ninjam/latest/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/current/Makefile b/linux/ecosystem/nodejs/current/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/current/Makefile +++ b/linux/ecosystem/nodejs/current/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/current/kaniko-build.py b/linux/ecosystem/nodejs/current/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/current/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/current/requirements.txt b/linux/ecosystem/nodejs/current/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/current/requirements.txt +++ b/linux/ecosystem/nodejs/current/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/lts/Makefile b/linux/ecosystem/nodejs/lts/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/lts/Makefile +++ b/linux/ecosystem/nodejs/lts/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/lts/kaniko-build.py b/linux/ecosystem/nodejs/lts/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/lts/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/lts/requirements.txt b/linux/ecosystem/nodejs/lts/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/lts/requirements.txt +++ b/linux/ecosystem/nodejs/lts/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node0.12/Makefile b/linux/ecosystem/nodejs/node0.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node0.12/Makefile +++ b/linux/ecosystem/nodejs/node0.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node0.12/kaniko-build.py b/linux/ecosystem/nodejs/node0.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node0.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node0.12/requirements.txt b/linux/ecosystem/nodejs/node0.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node0.12/requirements.txt +++ b/linux/ecosystem/nodejs/node0.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node10/Makefile b/linux/ecosystem/nodejs/node10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node10/Makefile +++ b/linux/ecosystem/nodejs/node10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node10/kaniko-build.py b/linux/ecosystem/nodejs/node10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node10/requirements.txt b/linux/ecosystem/nodejs/node10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node10/requirements.txt +++ b/linux/ecosystem/nodejs/node10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node11/Makefile b/linux/ecosystem/nodejs/node11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node11/Makefile +++ b/linux/ecosystem/nodejs/node11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node11/kaniko-build.py b/linux/ecosystem/nodejs/node11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node11/requirements.txt b/linux/ecosystem/nodejs/node11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node11/requirements.txt +++ b/linux/ecosystem/nodejs/node11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node12/Makefile b/linux/ecosystem/nodejs/node12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node12/Makefile +++ b/linux/ecosystem/nodejs/node12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node12/kaniko-build.py b/linux/ecosystem/nodejs/node12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node12/requirements.txt b/linux/ecosystem/nodejs/node12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node12/requirements.txt +++ b/linux/ecosystem/nodejs/node12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node13/Makefile b/linux/ecosystem/nodejs/node13/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node13/Makefile +++ b/linux/ecosystem/nodejs/node13/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node13/kaniko-build.py b/linux/ecosystem/nodejs/node13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node13/requirements.txt b/linux/ecosystem/nodejs/node13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node13/requirements.txt +++ b/linux/ecosystem/nodejs/node13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node14/Makefile b/linux/ecosystem/nodejs/node14/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node14/Makefile +++ b/linux/ecosystem/nodejs/node14/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node14/kaniko-build.py b/linux/ecosystem/nodejs/node14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node14/requirements.txt b/linux/ecosystem/nodejs/node14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node14/requirements.txt +++ b/linux/ecosystem/nodejs/node14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node15/Makefile b/linux/ecosystem/nodejs/node15/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node15/Makefile +++ b/linux/ecosystem/nodejs/node15/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node15/kaniko-build.py b/linux/ecosystem/nodejs/node15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node15/requirements.txt b/linux/ecosystem/nodejs/node15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node15/requirements.txt +++ b/linux/ecosystem/nodejs/node15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node16/Makefile b/linux/ecosystem/nodejs/node16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node16/Makefile +++ b/linux/ecosystem/nodejs/node16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node16/kaniko-build.py b/linux/ecosystem/nodejs/node16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node16/requirements.txt b/linux/ecosystem/nodejs/node16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node16/requirements.txt +++ b/linux/ecosystem/nodejs/node16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node17/Makefile b/linux/ecosystem/nodejs/node17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node17/Makefile +++ b/linux/ecosystem/nodejs/node17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node17/kaniko-build.py b/linux/ecosystem/nodejs/node17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node17/requirements.txt b/linux/ecosystem/nodejs/node17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node17/requirements.txt +++ b/linux/ecosystem/nodejs/node17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node18/Makefile b/linux/ecosystem/nodejs/node18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node18/Makefile +++ b/linux/ecosystem/nodejs/node18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node18/kaniko-build.py b/linux/ecosystem/nodejs/node18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node18/requirements.txt b/linux/ecosystem/nodejs/node18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node18/requirements.txt +++ b/linux/ecosystem/nodejs/node18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node19/Makefile b/linux/ecosystem/nodejs/node19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node19/Makefile +++ b/linux/ecosystem/nodejs/node19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node19/kaniko-build.py b/linux/ecosystem/nodejs/node19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node19/requirements.txt b/linux/ecosystem/nodejs/node19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node19/requirements.txt +++ b/linux/ecosystem/nodejs/node19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node20/Makefile b/linux/ecosystem/nodejs/node20/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node20/Makefile +++ b/linux/ecosystem/nodejs/node20/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node20/kaniko-build.py b/linux/ecosystem/nodejs/node20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node20/requirements.txt b/linux/ecosystem/nodejs/node20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node20/requirements.txt +++ b/linux/ecosystem/nodejs/node20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node21/Makefile b/linux/ecosystem/nodejs/node21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node21/Makefile +++ b/linux/ecosystem/nodejs/node21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node21/kaniko-build.py b/linux/ecosystem/nodejs/node21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node21/requirements.txt b/linux/ecosystem/nodejs/node21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node21/requirements.txt +++ b/linux/ecosystem/nodejs/node21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node22/Makefile b/linux/ecosystem/nodejs/node22/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node22/Makefile +++ b/linux/ecosystem/nodejs/node22/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node22/kaniko-build.py b/linux/ecosystem/nodejs/node22/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node22/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node22/requirements.txt b/linux/ecosystem/nodejs/node22/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node22/requirements.txt +++ b/linux/ecosystem/nodejs/node22/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node4/Makefile b/linux/ecosystem/nodejs/node4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node4/Makefile +++ b/linux/ecosystem/nodejs/node4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node4/kaniko-build.py b/linux/ecosystem/nodejs/node4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node4/requirements.txt b/linux/ecosystem/nodejs/node4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node4/requirements.txt +++ b/linux/ecosystem/nodejs/node4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node5/Makefile b/linux/ecosystem/nodejs/node5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node5/Makefile +++ b/linux/ecosystem/nodejs/node5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node5/kaniko-build.py b/linux/ecosystem/nodejs/node5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node5/requirements.txt b/linux/ecosystem/nodejs/node5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node5/requirements.txt +++ b/linux/ecosystem/nodejs/node5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node6/Makefile b/linux/ecosystem/nodejs/node6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node6/Makefile +++ b/linux/ecosystem/nodejs/node6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node6/kaniko-build.py b/linux/ecosystem/nodejs/node6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node6/requirements.txt b/linux/ecosystem/nodejs/node6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node6/requirements.txt +++ b/linux/ecosystem/nodejs/node6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node7/Makefile b/linux/ecosystem/nodejs/node7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node7/Makefile +++ b/linux/ecosystem/nodejs/node7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node7/kaniko-build.py b/linux/ecosystem/nodejs/node7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node7/requirements.txt b/linux/ecosystem/nodejs/node7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node7/requirements.txt +++ b/linux/ecosystem/nodejs/node7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node8/Makefile b/linux/ecosystem/nodejs/node8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node8/Makefile +++ b/linux/ecosystem/nodejs/node8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node8/kaniko-build.py b/linux/ecosystem/nodejs/node8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node8/requirements.txt b/linux/ecosystem/nodejs/node8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node8/requirements.txt +++ b/linux/ecosystem/nodejs/node8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/nodejs/node9/Makefile b/linux/ecosystem/nodejs/node9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/nodejs/node9/Makefile +++ b/linux/ecosystem/nodejs/node9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/nodejs/node9/kaniko-build.py b/linux/ecosystem/nodejs/node9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/nodejs/node9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/nodejs/node9/requirements.txt b/linux/ecosystem/nodejs/node9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/nodejs/node9/requirements.txt +++ b/linux/ecosystem/nodejs/node9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/opentracker/Makefile b/linux/ecosystem/opentracker/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/opentracker/Makefile +++ b/linux/ecosystem/opentracker/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/opentracker/kaniko-build.py b/linux/ecosystem/opentracker/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/opentracker/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/opentracker/requirements.txt b/linux/ecosystem/opentracker/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/opentracker/requirements.txt +++ b/linux/ecosystem/opentracker/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/base/r16.2/Makefile b/linux/ecosystem/perforce/base/r16.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/base/r16.2/Makefile +++ b/linux/ecosystem/perforce/base/r16.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/base/r16.2/kaniko-build.py b/linux/ecosystem/perforce/base/r16.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/base/r16.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/base/r16.2/requirements.txt b/linux/ecosystem/perforce/base/r16.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/base/r16.2/requirements.txt +++ b/linux/ecosystem/perforce/base/r16.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/base/r17.1/Makefile b/linux/ecosystem/perforce/base/r17.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/base/r17.1/Makefile +++ b/linux/ecosystem/perforce/base/r17.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/base/r17.1/kaniko-build.py b/linux/ecosystem/perforce/base/r17.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/base/r17.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/base/r17.1/requirements.txt b/linux/ecosystem/perforce/base/r17.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/base/r17.1/requirements.txt +++ b/linux/ecosystem/perforce/base/r17.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/base/r17.2/Makefile b/linux/ecosystem/perforce/base/r17.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/base/r17.2/Makefile +++ b/linux/ecosystem/perforce/base/r17.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/base/r17.2/kaniko-build.py b/linux/ecosystem/perforce/base/r17.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/base/r17.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/base/r17.2/requirements.txt b/linux/ecosystem/perforce/base/r17.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/base/r17.2/requirements.txt +++ b/linux/ecosystem/perforce/base/r17.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/base/r18.1/Makefile b/linux/ecosystem/perforce/base/r18.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/base/r18.1/Makefile +++ b/linux/ecosystem/perforce/base/r18.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/base/r18.1/kaniko-build.py b/linux/ecosystem/perforce/base/r18.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/base/r18.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/base/r18.1/requirements.txt b/linux/ecosystem/perforce/base/r18.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/base/r18.1/requirements.txt +++ b/linux/ecosystem/perforce/base/r18.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/base/r18.2/Makefile b/linux/ecosystem/perforce/base/r18.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/base/r18.2/Makefile +++ b/linux/ecosystem/perforce/base/r18.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/base/r18.2/kaniko-build.py b/linux/ecosystem/perforce/base/r18.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/base/r18.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/base/r18.2/requirements.txt b/linux/ecosystem/perforce/base/r18.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/base/r18.2/requirements.txt +++ b/linux/ecosystem/perforce/base/r18.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/base/r19.1/Makefile b/linux/ecosystem/perforce/base/r19.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/base/r19.1/Makefile +++ b/linux/ecosystem/perforce/base/r19.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/base/r19.1/kaniko-build.py b/linux/ecosystem/perforce/base/r19.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/base/r19.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/base/r19.1/requirements.txt b/linux/ecosystem/perforce/base/r19.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/base/r19.1/requirements.txt +++ b/linux/ecosystem/perforce/base/r19.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/base/r19.2/Makefile b/linux/ecosystem/perforce/base/r19.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/base/r19.2/Makefile +++ b/linux/ecosystem/perforce/base/r19.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/base/r19.2/kaniko-build.py b/linux/ecosystem/perforce/base/r19.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/base/r19.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/base/r19.2/requirements.txt b/linux/ecosystem/perforce/base/r19.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/base/r19.2/requirements.txt +++ b/linux/ecosystem/perforce/base/r19.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/base/r20.1/Makefile b/linux/ecosystem/perforce/base/r20.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/base/r20.1/Makefile +++ b/linux/ecosystem/perforce/base/r20.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/base/r20.1/kaniko-build.py b/linux/ecosystem/perforce/base/r20.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/base/r20.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/base/r20.1/requirements.txt b/linux/ecosystem/perforce/base/r20.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/base/r20.1/requirements.txt +++ b/linux/ecosystem/perforce/base/r20.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/base/r20.2/Makefile b/linux/ecosystem/perforce/base/r20.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/base/r20.2/Makefile +++ b/linux/ecosystem/perforce/base/r20.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/base/r20.2/kaniko-build.py b/linux/ecosystem/perforce/base/r20.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/base/r20.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/base/r20.2/requirements.txt b/linux/ecosystem/perforce/base/r20.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/base/r20.2/requirements.txt +++ b/linux/ecosystem/perforce/base/r20.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/base/r21.1/Makefile b/linux/ecosystem/perforce/base/r21.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/base/r21.1/Makefile +++ b/linux/ecosystem/perforce/base/r21.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/base/r21.1/kaniko-build.py b/linux/ecosystem/perforce/base/r21.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/base/r21.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/base/r21.1/requirements.txt b/linux/ecosystem/perforce/base/r21.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/base/r21.1/requirements.txt +++ b/linux/ecosystem/perforce/base/r21.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/base/r21.2/Makefile b/linux/ecosystem/perforce/base/r21.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/base/r21.2/Makefile +++ b/linux/ecosystem/perforce/base/r21.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/base/r21.2/kaniko-build.py b/linux/ecosystem/perforce/base/r21.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/base/r21.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/base/r21.2/requirements.txt b/linux/ecosystem/perforce/base/r21.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/base/r21.2/requirements.txt +++ b/linux/ecosystem/perforce/base/r21.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/base/r22.1/Makefile b/linux/ecosystem/perforce/base/r22.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/base/r22.1/Makefile +++ b/linux/ecosystem/perforce/base/r22.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/base/r22.1/kaniko-build.py b/linux/ecosystem/perforce/base/r22.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/base/r22.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/base/r22.1/requirements.txt b/linux/ecosystem/perforce/base/r22.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/base/r22.1/requirements.txt +++ b/linux/ecosystem/perforce/base/r22.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/base/r23.1/Makefile b/linux/ecosystem/perforce/base/r23.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/base/r23.1/Makefile +++ b/linux/ecosystem/perforce/base/r23.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/base/r23.1/kaniko-build.py b/linux/ecosystem/perforce/base/r23.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/base/r23.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/base/r23.1/requirements.txt b/linux/ecosystem/perforce/base/r23.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/base/r23.1/requirements.txt +++ b/linux/ecosystem/perforce/base/r23.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/base/r23.2/Makefile b/linux/ecosystem/perforce/base/r23.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/base/r23.2/Makefile +++ b/linux/ecosystem/perforce/base/r23.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/base/r23.2/kaniko-build.py b/linux/ecosystem/perforce/base/r23.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/base/r23.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/base/r23.2/requirements.txt b/linux/ecosystem/perforce/base/r23.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/base/r23.2/requirements.txt +++ b/linux/ecosystem/perforce/base/r23.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/p4p/r16.2/Makefile b/linux/ecosystem/perforce/p4p/r16.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/p4p/r16.2/Makefile +++ b/linux/ecosystem/perforce/p4p/r16.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/p4p/r16.2/kaniko-build.py b/linux/ecosystem/perforce/p4p/r16.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/p4p/r16.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/p4p/r16.2/requirements.txt b/linux/ecosystem/perforce/p4p/r16.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/p4p/r16.2/requirements.txt +++ b/linux/ecosystem/perforce/p4p/r16.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/p4p/r17.1/Makefile b/linux/ecosystem/perforce/p4p/r17.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/p4p/r17.1/Makefile +++ b/linux/ecosystem/perforce/p4p/r17.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/p4p/r17.1/kaniko-build.py b/linux/ecosystem/perforce/p4p/r17.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/p4p/r17.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/p4p/r17.1/requirements.txt b/linux/ecosystem/perforce/p4p/r17.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/p4p/r17.1/requirements.txt +++ b/linux/ecosystem/perforce/p4p/r17.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/p4p/r17.2/Makefile b/linux/ecosystem/perforce/p4p/r17.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/p4p/r17.2/Makefile +++ b/linux/ecosystem/perforce/p4p/r17.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/p4p/r17.2/kaniko-build.py b/linux/ecosystem/perforce/p4p/r17.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/p4p/r17.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/p4p/r17.2/requirements.txt b/linux/ecosystem/perforce/p4p/r17.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/p4p/r17.2/requirements.txt +++ b/linux/ecosystem/perforce/p4p/r17.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/p4p/r18.1/Makefile b/linux/ecosystem/perforce/p4p/r18.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/p4p/r18.1/Makefile +++ b/linux/ecosystem/perforce/p4p/r18.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/p4p/r18.1/kaniko-build.py b/linux/ecosystem/perforce/p4p/r18.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/p4p/r18.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/p4p/r18.1/requirements.txt b/linux/ecosystem/perforce/p4p/r18.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/p4p/r18.1/requirements.txt +++ b/linux/ecosystem/perforce/p4p/r18.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/p4p/r18.2/Makefile b/linux/ecosystem/perforce/p4p/r18.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/p4p/r18.2/Makefile +++ b/linux/ecosystem/perforce/p4p/r18.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/p4p/r18.2/kaniko-build.py b/linux/ecosystem/perforce/p4p/r18.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/p4p/r18.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/p4p/r18.2/requirements.txt b/linux/ecosystem/perforce/p4p/r18.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/p4p/r18.2/requirements.txt +++ b/linux/ecosystem/perforce/p4p/r18.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/p4p/r19.1/Makefile b/linux/ecosystem/perforce/p4p/r19.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/p4p/r19.1/Makefile +++ b/linux/ecosystem/perforce/p4p/r19.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/p4p/r19.1/kaniko-build.py b/linux/ecosystem/perforce/p4p/r19.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/p4p/r19.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/p4p/r19.1/requirements.txt b/linux/ecosystem/perforce/p4p/r19.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/p4p/r19.1/requirements.txt +++ b/linux/ecosystem/perforce/p4p/r19.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/p4p/r19.2/Makefile b/linux/ecosystem/perforce/p4p/r19.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/p4p/r19.2/Makefile +++ b/linux/ecosystem/perforce/p4p/r19.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/p4p/r19.2/kaniko-build.py b/linux/ecosystem/perforce/p4p/r19.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/p4p/r19.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/p4p/r19.2/requirements.txt b/linux/ecosystem/perforce/p4p/r19.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/p4p/r19.2/requirements.txt +++ b/linux/ecosystem/perforce/p4p/r19.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/p4p/r20.1/Makefile b/linux/ecosystem/perforce/p4p/r20.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/p4p/r20.1/Makefile +++ b/linux/ecosystem/perforce/p4p/r20.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/p4p/r20.1/kaniko-build.py b/linux/ecosystem/perforce/p4p/r20.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/p4p/r20.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/p4p/r20.1/requirements.txt b/linux/ecosystem/perforce/p4p/r20.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/p4p/r20.1/requirements.txt +++ b/linux/ecosystem/perforce/p4p/r20.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/p4p/r20.2/Makefile b/linux/ecosystem/perforce/p4p/r20.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/p4p/r20.2/Makefile +++ b/linux/ecosystem/perforce/p4p/r20.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/p4p/r20.2/kaniko-build.py b/linux/ecosystem/perforce/p4p/r20.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/p4p/r20.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/p4p/r20.2/requirements.txt b/linux/ecosystem/perforce/p4p/r20.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/p4p/r20.2/requirements.txt +++ b/linux/ecosystem/perforce/p4p/r20.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/p4p/r21.1/Makefile b/linux/ecosystem/perforce/p4p/r21.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/p4p/r21.1/Makefile +++ b/linux/ecosystem/perforce/p4p/r21.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/p4p/r21.1/kaniko-build.py b/linux/ecosystem/perforce/p4p/r21.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/p4p/r21.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/p4p/r21.1/requirements.txt b/linux/ecosystem/perforce/p4p/r21.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/p4p/r21.1/requirements.txt +++ b/linux/ecosystem/perforce/p4p/r21.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/p4p/r21.2/Makefile b/linux/ecosystem/perforce/p4p/r21.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/p4p/r21.2/Makefile +++ b/linux/ecosystem/perforce/p4p/r21.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/p4p/r21.2/kaniko-build.py b/linux/ecosystem/perforce/p4p/r21.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/p4p/r21.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/p4p/r21.2/requirements.txt b/linux/ecosystem/perforce/p4p/r21.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/p4p/r21.2/requirements.txt +++ b/linux/ecosystem/perforce/p4p/r21.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/p4p/r22.1/Makefile b/linux/ecosystem/perforce/p4p/r22.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/p4p/r22.1/Makefile +++ b/linux/ecosystem/perforce/p4p/r22.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/p4p/r22.1/kaniko-build.py b/linux/ecosystem/perforce/p4p/r22.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/p4p/r22.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/p4p/r22.1/requirements.txt b/linux/ecosystem/perforce/p4p/r22.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/p4p/r22.1/requirements.txt +++ b/linux/ecosystem/perforce/p4p/r22.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/p4p/r23.1/Makefile b/linux/ecosystem/perforce/p4p/r23.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/p4p/r23.1/Makefile +++ b/linux/ecosystem/perforce/p4p/r23.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/p4p/r23.1/kaniko-build.py b/linux/ecosystem/perforce/p4p/r23.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/p4p/r23.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/p4p/r23.1/requirements.txt b/linux/ecosystem/perforce/p4p/r23.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/p4p/r23.1/requirements.txt +++ b/linux/ecosystem/perforce/p4p/r23.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/perforce/p4p/r23.2/Makefile b/linux/ecosystem/perforce/p4p/r23.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/perforce/p4p/r23.2/Makefile +++ b/linux/ecosystem/perforce/p4p/r23.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/perforce/p4p/r23.2/kaniko-build.py b/linux/ecosystem/perforce/p4p/r23.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/perforce/p4p/r23.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/perforce/p4p/r23.2/requirements.txt b/linux/ecosystem/perforce/p4p/r23.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/perforce/p4p/r23.2/requirements.txt +++ b/linux/ecosystem/perforce/p4p/r23.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/php/php5.5/Makefile b/linux/ecosystem/php/php5.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/php/php5.5/Makefile +++ b/linux/ecosystem/php/php5.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/php/php5.5/kaniko-build.py b/linux/ecosystem/php/php5.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/php/php5.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/php/php5.5/requirements.txt b/linux/ecosystem/php/php5.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/php/php5.5/requirements.txt +++ b/linux/ecosystem/php/php5.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/php/php7.0/Makefile b/linux/ecosystem/php/php7.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/php/php7.0/Makefile +++ b/linux/ecosystem/php/php7.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/php/php7.0/kaniko-build.py b/linux/ecosystem/php/php7.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/php/php7.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/php/php7.0/requirements.txt b/linux/ecosystem/php/php7.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/php/php7.0/requirements.txt +++ b/linux/ecosystem/php/php7.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/php/php7.1/Makefile b/linux/ecosystem/php/php7.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/php/php7.1/Makefile +++ b/linux/ecosystem/php/php7.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/php/php7.1/kaniko-build.py b/linux/ecosystem/php/php7.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/php/php7.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/php/php7.1/requirements.txt b/linux/ecosystem/php/php7.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/php/php7.1/requirements.txt +++ b/linux/ecosystem/php/php7.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/php/php7.2/Makefile b/linux/ecosystem/php/php7.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/php/php7.2/Makefile +++ b/linux/ecosystem/php/php7.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/php/php7.2/kaniko-build.py b/linux/ecosystem/php/php7.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/php/php7.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/php/php7.2/requirements.txt b/linux/ecosystem/php/php7.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/php/php7.2/requirements.txt +++ b/linux/ecosystem/php/php7.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/php/php7.3/Makefile b/linux/ecosystem/php/php7.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/php/php7.3/Makefile +++ b/linux/ecosystem/php/php7.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/php/php7.3/kaniko-build.py b/linux/ecosystem/php/php7.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/php/php7.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/php/php7.3/requirements.txt b/linux/ecosystem/php/php7.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/php/php7.3/requirements.txt +++ b/linux/ecosystem/php/php7.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/php/php7.4/Makefile b/linux/ecosystem/php/php7.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/php/php7.4/Makefile +++ b/linux/ecosystem/php/php7.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/php/php7.4/kaniko-build.py b/linux/ecosystem/php/php7.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/php/php7.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/php/php7.4/requirements.txt b/linux/ecosystem/php/php7.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/php/php7.4/requirements.txt +++ b/linux/ecosystem/php/php7.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/php/php8.0/Makefile b/linux/ecosystem/php/php8.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/php/php8.0/Makefile +++ b/linux/ecosystem/php/php8.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/php/php8.0/kaniko-build.py b/linux/ecosystem/php/php8.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/php/php8.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/php/php8.0/requirements.txt b/linux/ecosystem/php/php8.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/php/php8.0/requirements.txt +++ b/linux/ecosystem/php/php8.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/php/php8.1/Makefile b/linux/ecosystem/php/php8.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/php/php8.1/Makefile +++ b/linux/ecosystem/php/php8.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/php/php8.1/kaniko-build.py b/linux/ecosystem/php/php8.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/php/php8.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/php/php8.1/requirements.txt b/linux/ecosystem/php/php8.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/php/php8.1/requirements.txt +++ b/linux/ecosystem/php/php8.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/php/php8.2/Makefile b/linux/ecosystem/php/php8.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/php/php8.2/Makefile +++ b/linux/ecosystem/php/php8.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/php/php8.2/kaniko-build.py b/linux/ecosystem/php/php8.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/php/php8.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/php/php8.2/requirements.txt b/linux/ecosystem/php/php8.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/php/php8.2/requirements.txt +++ b/linux/ecosystem/php/php8.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/php/php8.3/Makefile b/linux/ecosystem/php/php8.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/php/php8.3/Makefile +++ b/linux/ecosystem/php/php8.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/php/php8.3/kaniko-build.py b/linux/ecosystem/php/php8.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/php/php8.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/php/php8.3/requirements.txt b/linux/ecosystem/php/php8.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/php/php8.3/requirements.txt +++ b/linux/ecosystem/php/php8.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/10/Makefile b/linux/ecosystem/postgres/10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/10/Makefile +++ b/linux/ecosystem/postgres/10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/10/kaniko-build.py b/linux/ecosystem/postgres/10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/10/requirements.txt b/linux/ecosystem/postgres/10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/10/requirements.txt +++ b/linux/ecosystem/postgres/10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/11/Makefile b/linux/ecosystem/postgres/11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/11/Makefile +++ b/linux/ecosystem/postgres/11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/11/kaniko-build.py b/linux/ecosystem/postgres/11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/11/requirements.txt b/linux/ecosystem/postgres/11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/11/requirements.txt +++ b/linux/ecosystem/postgres/11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/12/Makefile b/linux/ecosystem/postgres/12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/12/Makefile +++ b/linux/ecosystem/postgres/12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/12/kaniko-build.py b/linux/ecosystem/postgres/12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/12/requirements.txt b/linux/ecosystem/postgres/12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/12/requirements.txt +++ b/linux/ecosystem/postgres/12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/13/Makefile b/linux/ecosystem/postgres/13/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/13/Makefile +++ b/linux/ecosystem/postgres/13/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/13/kaniko-build.py b/linux/ecosystem/postgres/13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/13/requirements.txt b/linux/ecosystem/postgres/13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/13/requirements.txt +++ b/linux/ecosystem/postgres/13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/14/Makefile b/linux/ecosystem/postgres/14/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/14/Makefile +++ b/linux/ecosystem/postgres/14/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/14/kaniko-build.py b/linux/ecosystem/postgres/14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/14/requirements.txt b/linux/ecosystem/postgres/14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/14/requirements.txt +++ b/linux/ecosystem/postgres/14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/15/Makefile b/linux/ecosystem/postgres/15/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/15/Makefile +++ b/linux/ecosystem/postgres/15/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/15/kaniko-build.py b/linux/ecosystem/postgres/15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/15/requirements.txt b/linux/ecosystem/postgres/15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/15/requirements.txt +++ b/linux/ecosystem/postgres/15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/16/Makefile b/linux/ecosystem/postgres/16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/16/Makefile +++ b/linux/ecosystem/postgres/16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/16/kaniko-build.py b/linux/ecosystem/postgres/16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/16/requirements.txt b/linux/ecosystem/postgres/16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/16/requirements.txt +++ b/linux/ecosystem/postgres/16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/8.2/Makefile b/linux/ecosystem/postgres/8.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/8.2/Makefile +++ b/linux/ecosystem/postgres/8.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/8.2/kaniko-build.py b/linux/ecosystem/postgres/8.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/8.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/8.2/requirements.txt b/linux/ecosystem/postgres/8.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/8.2/requirements.txt +++ b/linux/ecosystem/postgres/8.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/8.3/Makefile b/linux/ecosystem/postgres/8.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/8.3/Makefile +++ b/linux/ecosystem/postgres/8.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/8.3/kaniko-build.py b/linux/ecosystem/postgres/8.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/8.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/8.3/requirements.txt b/linux/ecosystem/postgres/8.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/8.3/requirements.txt +++ b/linux/ecosystem/postgres/8.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/8.4/Makefile b/linux/ecosystem/postgres/8.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/8.4/Makefile +++ b/linux/ecosystem/postgres/8.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/8.4/kaniko-build.py b/linux/ecosystem/postgres/8.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/8.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/8.4/requirements.txt b/linux/ecosystem/postgres/8.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/8.4/requirements.txt +++ b/linux/ecosystem/postgres/8.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/9.0/Makefile b/linux/ecosystem/postgres/9.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/9.0/Makefile +++ b/linux/ecosystem/postgres/9.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/9.0/kaniko-build.py b/linux/ecosystem/postgres/9.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/9.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/9.0/requirements.txt b/linux/ecosystem/postgres/9.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/9.0/requirements.txt +++ b/linux/ecosystem/postgres/9.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/9.1/Makefile b/linux/ecosystem/postgres/9.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/9.1/Makefile +++ b/linux/ecosystem/postgres/9.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/9.1/kaniko-build.py b/linux/ecosystem/postgres/9.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/9.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/9.1/requirements.txt b/linux/ecosystem/postgres/9.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/9.1/requirements.txt +++ b/linux/ecosystem/postgres/9.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/9.2/Makefile b/linux/ecosystem/postgres/9.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/9.2/Makefile +++ b/linux/ecosystem/postgres/9.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/9.2/kaniko-build.py b/linux/ecosystem/postgres/9.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/9.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/9.2/requirements.txt b/linux/ecosystem/postgres/9.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/9.2/requirements.txt +++ b/linux/ecosystem/postgres/9.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/9.3/Makefile b/linux/ecosystem/postgres/9.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/9.3/Makefile +++ b/linux/ecosystem/postgres/9.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/9.3/kaniko-build.py b/linux/ecosystem/postgres/9.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/9.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/9.3/requirements.txt b/linux/ecosystem/postgres/9.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/9.3/requirements.txt +++ b/linux/ecosystem/postgres/9.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/9.4/Makefile b/linux/ecosystem/postgres/9.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/9.4/Makefile +++ b/linux/ecosystem/postgres/9.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/9.4/kaniko-build.py b/linux/ecosystem/postgres/9.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/9.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/9.4/requirements.txt b/linux/ecosystem/postgres/9.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/9.4/requirements.txt +++ b/linux/ecosystem/postgres/9.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/9.5/Makefile b/linux/ecosystem/postgres/9.5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/9.5/Makefile +++ b/linux/ecosystem/postgres/9.5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/9.5/kaniko-build.py b/linux/ecosystem/postgres/9.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/9.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/9.5/requirements.txt b/linux/ecosystem/postgres/9.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/9.5/requirements.txt +++ b/linux/ecosystem/postgres/9.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/9.6/Makefile b/linux/ecosystem/postgres/9.6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/9.6/Makefile +++ b/linux/ecosystem/postgres/9.6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/9.6/kaniko-build.py b/linux/ecosystem/postgres/9.6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/9.6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/9.6/requirements.txt b/linux/ecosystem/postgres/9.6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/9.6/requirements.txt +++ b/linux/ecosystem/postgres/9.6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/postgres/latest/Makefile b/linux/ecosystem/postgres/latest/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/postgres/latest/Makefile +++ b/linux/ecosystem/postgres/latest/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/postgres/latest/kaniko-build.py b/linux/ecosystem/postgres/latest/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/postgres/latest/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/postgres/latest/requirements.txt b/linux/ecosystem/postgres/latest/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/postgres/latest/requirements.txt +++ b/linux/ecosystem/postgres/latest/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.4.0/Makefile b/linux/ecosystem/qbittorrent/4.4.0/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.4.0/Makefile +++ b/linux/ecosystem/qbittorrent/4.4.0/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.4.0/kaniko-build.py b/linux/ecosystem/qbittorrent/4.4.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.4.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.4.0/requirements.txt b/linux/ecosystem/qbittorrent/4.4.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.4.0/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.4.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.4.1/Makefile b/linux/ecosystem/qbittorrent/4.4.1/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.4.1/Makefile +++ b/linux/ecosystem/qbittorrent/4.4.1/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.4.1/kaniko-build.py b/linux/ecosystem/qbittorrent/4.4.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.4.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.4.1/requirements.txt b/linux/ecosystem/qbittorrent/4.4.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.4.1/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.4.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.4.2/Makefile b/linux/ecosystem/qbittorrent/4.4.2/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.4.2/Makefile +++ b/linux/ecosystem/qbittorrent/4.4.2/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.4.2/kaniko-build.py b/linux/ecosystem/qbittorrent/4.4.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.4.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.4.2/requirements.txt b/linux/ecosystem/qbittorrent/4.4.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.4.2/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.4.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.4.3.1/Makefile b/linux/ecosystem/qbittorrent/4.4.3.1/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.4.3.1/Makefile +++ b/linux/ecosystem/qbittorrent/4.4.3.1/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.4.3.1/kaniko-build.py b/linux/ecosystem/qbittorrent/4.4.3.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.4.3.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.4.3.1/requirements.txt b/linux/ecosystem/qbittorrent/4.4.3.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.4.3.1/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.4.3.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.4.4/Makefile b/linux/ecosystem/qbittorrent/4.4.4/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.4.4/Makefile +++ b/linux/ecosystem/qbittorrent/4.4.4/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.4.4/kaniko-build.py b/linux/ecosystem/qbittorrent/4.4.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.4.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.4.4/requirements.txt b/linux/ecosystem/qbittorrent/4.4.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.4.4/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.4.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.4.5/Makefile b/linux/ecosystem/qbittorrent/4.4.5/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.4.5/Makefile +++ b/linux/ecosystem/qbittorrent/4.4.5/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.4.5/kaniko-build.py b/linux/ecosystem/qbittorrent/4.4.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.4.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.4.5/requirements.txt b/linux/ecosystem/qbittorrent/4.4.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.4.5/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.4.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.5.0/Makefile b/linux/ecosystem/qbittorrent/4.5.0/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.5.0/Makefile +++ b/linux/ecosystem/qbittorrent/4.5.0/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.5.0/kaniko-build.py b/linux/ecosystem/qbittorrent/4.5.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.5.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.5.0/requirements.txt b/linux/ecosystem/qbittorrent/4.5.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.5.0/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.5.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.5.1/Makefile b/linux/ecosystem/qbittorrent/4.5.1/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.5.1/Makefile +++ b/linux/ecosystem/qbittorrent/4.5.1/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.5.1/kaniko-build.py b/linux/ecosystem/qbittorrent/4.5.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.5.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.5.1/requirements.txt b/linux/ecosystem/qbittorrent/4.5.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.5.1/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.5.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.5.2/Makefile b/linux/ecosystem/qbittorrent/4.5.2/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.5.2/Makefile +++ b/linux/ecosystem/qbittorrent/4.5.2/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.5.2/kaniko-build.py b/linux/ecosystem/qbittorrent/4.5.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.5.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.5.2/requirements.txt b/linux/ecosystem/qbittorrent/4.5.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.5.2/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.5.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.5.3/Makefile b/linux/ecosystem/qbittorrent/4.5.3/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.5.3/Makefile +++ b/linux/ecosystem/qbittorrent/4.5.3/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.5.3/kaniko-build.py b/linux/ecosystem/qbittorrent/4.5.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.5.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.5.3/requirements.txt b/linux/ecosystem/qbittorrent/4.5.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.5.3/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.5.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.5.4/Makefile b/linux/ecosystem/qbittorrent/4.5.4/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.5.4/Makefile +++ b/linux/ecosystem/qbittorrent/4.5.4/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.5.4/kaniko-build.py b/linux/ecosystem/qbittorrent/4.5.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.5.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.5.4/requirements.txt b/linux/ecosystem/qbittorrent/4.5.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.5.4/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.5.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.5.5/Makefile b/linux/ecosystem/qbittorrent/4.5.5/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.5.5/Makefile +++ b/linux/ecosystem/qbittorrent/4.5.5/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.5.5/kaniko-build.py b/linux/ecosystem/qbittorrent/4.5.5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.5.5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.5.5/requirements.txt b/linux/ecosystem/qbittorrent/4.5.5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.5.5/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.5.5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.6.0/Makefile b/linux/ecosystem/qbittorrent/4.6.0/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.6.0/Makefile +++ b/linux/ecosystem/qbittorrent/4.6.0/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.6.0/kaniko-build.py b/linux/ecosystem/qbittorrent/4.6.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.6.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.6.0/requirements.txt b/linux/ecosystem/qbittorrent/4.6.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.6.0/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.6.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.6.1/Makefile b/linux/ecosystem/qbittorrent/4.6.1/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.6.1/Makefile +++ b/linux/ecosystem/qbittorrent/4.6.1/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.6.1/kaniko-build.py b/linux/ecosystem/qbittorrent/4.6.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.6.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.6.1/requirements.txt b/linux/ecosystem/qbittorrent/4.6.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.6.1/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.6.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.6.2/Makefile b/linux/ecosystem/qbittorrent/4.6.2/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.6.2/Makefile +++ b/linux/ecosystem/qbittorrent/4.6.2/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.6.2/kaniko-build.py b/linux/ecosystem/qbittorrent/4.6.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.6.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.6.2/requirements.txt b/linux/ecosystem/qbittorrent/4.6.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.6.2/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.6.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.6.3/Makefile b/linux/ecosystem/qbittorrent/4.6.3/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.6.3/Makefile +++ b/linux/ecosystem/qbittorrent/4.6.3/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.6.3/kaniko-build.py b/linux/ecosystem/qbittorrent/4.6.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.6.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.6.3/requirements.txt b/linux/ecosystem/qbittorrent/4.6.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.6.3/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.6.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/4.6.4/Makefile b/linux/ecosystem/qbittorrent/4.6.4/Makefile index 3f22f2b23..b1930a89e 100644 --- a/linux/ecosystem/qbittorrent/4.6.4/Makefile +++ b/linux/ecosystem/qbittorrent/4.6.4/Makefile @@ -14,7 +14,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/4.6.4/kaniko-build.py b/linux/ecosystem/qbittorrent/4.6.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/4.6.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/4.6.4/requirements.txt b/linux/ecosystem/qbittorrent/4.6.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/4.6.4/requirements.txt +++ b/linux/ecosystem/qbittorrent/4.6.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/qbittorrent/testing/Makefile b/linux/ecosystem/qbittorrent/testing/Makefile index fb4042172..e9d386ab2 100644 --- a/linux/ecosystem/qbittorrent/testing/Makefile +++ b/linux/ecosystem/qbittorrent/testing/Makefile @@ -13,7 +13,7 @@ build: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/qbittorrent/testing/kaniko-build.py b/linux/ecosystem/qbittorrent/testing/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/qbittorrent/testing/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/qbittorrent/testing/requirements.txt b/linux/ecosystem/qbittorrent/testing/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/qbittorrent/testing/requirements.txt +++ b/linux/ecosystem/qbittorrent/testing/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/retracker/Makefile b/linux/ecosystem/retracker/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/retracker/Makefile +++ b/linux/ecosystem/retracker/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/retracker/kaniko-build.py b/linux/ecosystem/retracker/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/retracker/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/retracker/requirements.txt b/linux/ecosystem/retracker/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/retracker/requirements.txt +++ b/linux/ecosystem/retracker/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/Makefile b/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/Makefile +++ b/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/kaniko-build.py b/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/requirements.txt b/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/requirements.txt +++ b/linux/ecosystem/teamcity/agent/amxx-sdk/1.10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/Makefile b/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/Makefile +++ b/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/kaniko-build.py b/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/requirements.txt b/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/requirements.txt +++ b/linux/ecosystem/teamcity/agent/amxx-sdk/1.9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/android-sdk/jdk11/Makefile b/linux/ecosystem/teamcity/agent/android-sdk/jdk11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/android-sdk/jdk11/Makefile +++ b/linux/ecosystem/teamcity/agent/android-sdk/jdk11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/android-sdk/jdk11/kaniko-build.py b/linux/ecosystem/teamcity/agent/android-sdk/jdk11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/android-sdk/jdk11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/android-sdk/jdk11/requirements.txt b/linux/ecosystem/teamcity/agent/android-sdk/jdk11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/android-sdk/jdk11/requirements.txt +++ b/linux/ecosystem/teamcity/agent/android-sdk/jdk11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/android-sdk/jdk17/Makefile b/linux/ecosystem/teamcity/agent/android-sdk/jdk17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/android-sdk/jdk17/Makefile +++ b/linux/ecosystem/teamcity/agent/android-sdk/jdk17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/android-sdk/jdk17/kaniko-build.py b/linux/ecosystem/teamcity/agent/android-sdk/jdk17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/android-sdk/jdk17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/android-sdk/jdk17/requirements.txt b/linux/ecosystem/teamcity/agent/android-sdk/jdk17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/android-sdk/jdk17/requirements.txt +++ b/linux/ecosystem/teamcity/agent/android-sdk/jdk17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/android-sdk/jdk8/Makefile b/linux/ecosystem/teamcity/agent/android-sdk/jdk8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/android-sdk/jdk8/Makefile +++ b/linux/ecosystem/teamcity/agent/android-sdk/jdk8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/android-sdk/jdk8/kaniko-build.py b/linux/ecosystem/teamcity/agent/android-sdk/jdk8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/android-sdk/jdk8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/android-sdk/jdk8/requirements.txt b/linux/ecosystem/teamcity/agent/android-sdk/jdk8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/android-sdk/jdk8/requirements.txt +++ b/linux/ecosystem/teamcity/agent/android-sdk/jdk8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/atlassian-sdk/Makefile b/linux/ecosystem/teamcity/agent/atlassian-sdk/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/atlassian-sdk/Makefile +++ b/linux/ecosystem/teamcity/agent/atlassian-sdk/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/atlassian-sdk/kaniko-build.py b/linux/ecosystem/teamcity/agent/atlassian-sdk/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/atlassian-sdk/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/atlassian-sdk/requirements.txt b/linux/ecosystem/teamcity/agent/atlassian-sdk/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/atlassian-sdk/requirements.txt +++ b/linux/ecosystem/teamcity/agent/atlassian-sdk/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/dotnet-sdk/Makefile b/linux/ecosystem/teamcity/agent/dotnet-sdk/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/dotnet-sdk/Makefile +++ b/linux/ecosystem/teamcity/agent/dotnet-sdk/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/dotnet-sdk/kaniko-build.py b/linux/ecosystem/teamcity/agent/dotnet-sdk/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/dotnet-sdk/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/dotnet-sdk/requirements.txt b/linux/ecosystem/teamcity/agent/dotnet-sdk/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/dotnet-sdk/requirements.txt +++ b/linux/ecosystem/teamcity/agent/dotnet-sdk/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/latest/jdk11/Makefile b/linux/ecosystem/teamcity/agent/latest/jdk11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/latest/jdk11/Makefile +++ b/linux/ecosystem/teamcity/agent/latest/jdk11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/latest/jdk11/kaniko-build.py b/linux/ecosystem/teamcity/agent/latest/jdk11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/latest/jdk11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/latest/jdk11/requirements.txt b/linux/ecosystem/teamcity/agent/latest/jdk11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/latest/jdk11/requirements.txt +++ b/linux/ecosystem/teamcity/agent/latest/jdk11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/latest/jdk17/Makefile b/linux/ecosystem/teamcity/agent/latest/jdk17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/latest/jdk17/Makefile +++ b/linux/ecosystem/teamcity/agent/latest/jdk17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/latest/jdk17/kaniko-build.py b/linux/ecosystem/teamcity/agent/latest/jdk17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/latest/jdk17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/latest/jdk17/requirements.txt b/linux/ecosystem/teamcity/agent/latest/jdk17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/latest/jdk17/requirements.txt +++ b/linux/ecosystem/teamcity/agent/latest/jdk17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/latest/jdk21/Makefile b/linux/ecosystem/teamcity/agent/latest/jdk21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/latest/jdk21/Makefile +++ b/linux/ecosystem/teamcity/agent/latest/jdk21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/latest/jdk21/kaniko-build.py b/linux/ecosystem/teamcity/agent/latest/jdk21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/latest/jdk21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/latest/jdk21/requirements.txt b/linux/ecosystem/teamcity/agent/latest/jdk21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/latest/jdk21/requirements.txt +++ b/linux/ecosystem/teamcity/agent/latest/jdk21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/latest/jdk8/Makefile b/linux/ecosystem/teamcity/agent/latest/jdk8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/latest/jdk8/Makefile +++ b/linux/ecosystem/teamcity/agent/latest/jdk8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/latest/jdk8/kaniko-build.py b/linux/ecosystem/teamcity/agent/latest/jdk8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/latest/jdk8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/latest/jdk8/requirements.txt b/linux/ecosystem/teamcity/agent/latest/jdk8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/latest/jdk8/requirements.txt +++ b/linux/ecosystem/teamcity/agent/latest/jdk8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node0.12/Makefile b/linux/ecosystem/teamcity/agent/node0.12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node0.12/Makefile +++ b/linux/ecosystem/teamcity/agent/node0.12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node0.12/kaniko-build.py b/linux/ecosystem/teamcity/agent/node0.12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node0.12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node0.12/requirements.txt b/linux/ecosystem/teamcity/agent/node0.12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node0.12/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node0.12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node10/Makefile b/linux/ecosystem/teamcity/agent/node10/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node10/Makefile +++ b/linux/ecosystem/teamcity/agent/node10/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node10/kaniko-build.py b/linux/ecosystem/teamcity/agent/node10/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node10/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node10/requirements.txt b/linux/ecosystem/teamcity/agent/node10/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node10/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node10/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node11/Makefile b/linux/ecosystem/teamcity/agent/node11/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node11/Makefile +++ b/linux/ecosystem/teamcity/agent/node11/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node11/kaniko-build.py b/linux/ecosystem/teamcity/agent/node11/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node11/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node11/requirements.txt b/linux/ecosystem/teamcity/agent/node11/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node11/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node11/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node12/Makefile b/linux/ecosystem/teamcity/agent/node12/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node12/Makefile +++ b/linux/ecosystem/teamcity/agent/node12/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node12/kaniko-build.py b/linux/ecosystem/teamcity/agent/node12/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node12/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node12/requirements.txt b/linux/ecosystem/teamcity/agent/node12/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node12/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node12/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node13/Makefile b/linux/ecosystem/teamcity/agent/node13/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node13/Makefile +++ b/linux/ecosystem/teamcity/agent/node13/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node13/kaniko-build.py b/linux/ecosystem/teamcity/agent/node13/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node13/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node13/requirements.txt b/linux/ecosystem/teamcity/agent/node13/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node13/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node13/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node14/Makefile b/linux/ecosystem/teamcity/agent/node14/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node14/Makefile +++ b/linux/ecosystem/teamcity/agent/node14/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node14/kaniko-build.py b/linux/ecosystem/teamcity/agent/node14/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node14/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node14/requirements.txt b/linux/ecosystem/teamcity/agent/node14/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node14/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node14/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node15/Makefile b/linux/ecosystem/teamcity/agent/node15/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node15/Makefile +++ b/linux/ecosystem/teamcity/agent/node15/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node15/kaniko-build.py b/linux/ecosystem/teamcity/agent/node15/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node15/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node15/requirements.txt b/linux/ecosystem/teamcity/agent/node15/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node15/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node15/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node16/Makefile b/linux/ecosystem/teamcity/agent/node16/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node16/Makefile +++ b/linux/ecosystem/teamcity/agent/node16/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node16/kaniko-build.py b/linux/ecosystem/teamcity/agent/node16/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node16/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node16/requirements.txt b/linux/ecosystem/teamcity/agent/node16/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node16/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node16/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node17/Makefile b/linux/ecosystem/teamcity/agent/node17/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node17/Makefile +++ b/linux/ecosystem/teamcity/agent/node17/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node17/kaniko-build.py b/linux/ecosystem/teamcity/agent/node17/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node17/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node17/requirements.txt b/linux/ecosystem/teamcity/agent/node17/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node17/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node17/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node18/Makefile b/linux/ecosystem/teamcity/agent/node18/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node18/Makefile +++ b/linux/ecosystem/teamcity/agent/node18/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node18/kaniko-build.py b/linux/ecosystem/teamcity/agent/node18/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node18/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node18/requirements.txt b/linux/ecosystem/teamcity/agent/node18/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node18/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node18/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node19/Makefile b/linux/ecosystem/teamcity/agent/node19/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node19/Makefile +++ b/linux/ecosystem/teamcity/agent/node19/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node19/kaniko-build.py b/linux/ecosystem/teamcity/agent/node19/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node19/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node19/requirements.txt b/linux/ecosystem/teamcity/agent/node19/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node19/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node19/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node20/Makefile b/linux/ecosystem/teamcity/agent/node20/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node20/Makefile +++ b/linux/ecosystem/teamcity/agent/node20/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node20/kaniko-build.py b/linux/ecosystem/teamcity/agent/node20/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node20/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node20/requirements.txt b/linux/ecosystem/teamcity/agent/node20/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node20/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node20/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node21/Makefile b/linux/ecosystem/teamcity/agent/node21/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node21/Makefile +++ b/linux/ecosystem/teamcity/agent/node21/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node21/kaniko-build.py b/linux/ecosystem/teamcity/agent/node21/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node21/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node21/requirements.txt b/linux/ecosystem/teamcity/agent/node21/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node21/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node21/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node22/Makefile b/linux/ecosystem/teamcity/agent/node22/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node22/Makefile +++ b/linux/ecosystem/teamcity/agent/node22/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node22/kaniko-build.py b/linux/ecosystem/teamcity/agent/node22/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node22/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node22/requirements.txt b/linux/ecosystem/teamcity/agent/node22/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node22/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node22/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node4/Makefile b/linux/ecosystem/teamcity/agent/node4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node4/Makefile +++ b/linux/ecosystem/teamcity/agent/node4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node4/kaniko-build.py b/linux/ecosystem/teamcity/agent/node4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node4/requirements.txt b/linux/ecosystem/teamcity/agent/node4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node4/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node5/Makefile b/linux/ecosystem/teamcity/agent/node5/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node5/Makefile +++ b/linux/ecosystem/teamcity/agent/node5/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node5/kaniko-build.py b/linux/ecosystem/teamcity/agent/node5/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node5/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node5/requirements.txt b/linux/ecosystem/teamcity/agent/node5/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node5/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node5/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node6/Makefile b/linux/ecosystem/teamcity/agent/node6/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node6/Makefile +++ b/linux/ecosystem/teamcity/agent/node6/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node6/kaniko-build.py b/linux/ecosystem/teamcity/agent/node6/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node6/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node6/requirements.txt b/linux/ecosystem/teamcity/agent/node6/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node6/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node6/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node7/Makefile b/linux/ecosystem/teamcity/agent/node7/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node7/Makefile +++ b/linux/ecosystem/teamcity/agent/node7/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node7/kaniko-build.py b/linux/ecosystem/teamcity/agent/node7/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node7/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node7/requirements.txt b/linux/ecosystem/teamcity/agent/node7/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node7/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node7/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node8/Makefile b/linux/ecosystem/teamcity/agent/node8/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node8/Makefile +++ b/linux/ecosystem/teamcity/agent/node8/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node8/kaniko-build.py b/linux/ecosystem/teamcity/agent/node8/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node8/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node8/requirements.txt b/linux/ecosystem/teamcity/agent/node8/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node8/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node8/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/node9/Makefile b/linux/ecosystem/teamcity/agent/node9/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/node9/Makefile +++ b/linux/ecosystem/teamcity/agent/node9/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/node9/kaniko-build.py b/linux/ecosystem/teamcity/agent/node9/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/node9/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/node9/requirements.txt b/linux/ecosystem/teamcity/agent/node9/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/node9/requirements.txt +++ b/linux/ecosystem/teamcity/agent/node9/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/php7.2/Makefile b/linux/ecosystem/teamcity/agent/php7.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/php7.2/Makefile +++ b/linux/ecosystem/teamcity/agent/php7.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/php7.2/kaniko-build.py b/linux/ecosystem/teamcity/agent/php7.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/php7.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/php7.2/requirements.txt b/linux/ecosystem/teamcity/agent/php7.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/php7.2/requirements.txt +++ b/linux/ecosystem/teamcity/agent/php7.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/php7.3/Makefile b/linux/ecosystem/teamcity/agent/php7.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/php7.3/Makefile +++ b/linux/ecosystem/teamcity/agent/php7.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/php7.3/kaniko-build.py b/linux/ecosystem/teamcity/agent/php7.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/php7.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/php7.3/requirements.txt b/linux/ecosystem/teamcity/agent/php7.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/php7.3/requirements.txt +++ b/linux/ecosystem/teamcity/agent/php7.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/php7.4/Makefile b/linux/ecosystem/teamcity/agent/php7.4/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/php7.4/Makefile +++ b/linux/ecosystem/teamcity/agent/php7.4/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/php7.4/kaniko-build.py b/linux/ecosystem/teamcity/agent/php7.4/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/php7.4/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/php7.4/requirements.txt b/linux/ecosystem/teamcity/agent/php7.4/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/php7.4/requirements.txt +++ b/linux/ecosystem/teamcity/agent/php7.4/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/php8.0/Makefile b/linux/ecosystem/teamcity/agent/php8.0/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/php8.0/Makefile +++ b/linux/ecosystem/teamcity/agent/php8.0/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/php8.0/kaniko-build.py b/linux/ecosystem/teamcity/agent/php8.0/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/php8.0/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/php8.0/requirements.txt b/linux/ecosystem/teamcity/agent/php8.0/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/php8.0/requirements.txt +++ b/linux/ecosystem/teamcity/agent/php8.0/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/php8.1/Makefile b/linux/ecosystem/teamcity/agent/php8.1/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/php8.1/Makefile +++ b/linux/ecosystem/teamcity/agent/php8.1/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/php8.1/kaniko-build.py b/linux/ecosystem/teamcity/agent/php8.1/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/php8.1/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/php8.1/requirements.txt b/linux/ecosystem/teamcity/agent/php8.1/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/php8.1/requirements.txt +++ b/linux/ecosystem/teamcity/agent/php8.1/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/php8.2/Makefile b/linux/ecosystem/teamcity/agent/php8.2/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/php8.2/Makefile +++ b/linux/ecosystem/teamcity/agent/php8.2/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/php8.2/kaniko-build.py b/linux/ecosystem/teamcity/agent/php8.2/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/php8.2/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/php8.2/requirements.txt b/linux/ecosystem/teamcity/agent/php8.2/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/php8.2/requirements.txt +++ b/linux/ecosystem/teamcity/agent/php8.2/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/php8.3/Makefile b/linux/ecosystem/teamcity/agent/php8.3/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/php8.3/Makefile +++ b/linux/ecosystem/teamcity/agent/php8.3/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/php8.3/kaniko-build.py b/linux/ecosystem/teamcity/agent/php8.3/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/php8.3/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/php8.3/requirements.txt b/linux/ecosystem/teamcity/agent/php8.3/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/php8.3/requirements.txt +++ b/linux/ecosystem/teamcity/agent/php8.3/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/teamcity/agent/steam-sdk/Makefile b/linux/ecosystem/teamcity/agent/steam-sdk/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/teamcity/agent/steam-sdk/Makefile +++ b/linux/ecosystem/teamcity/agent/steam-sdk/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/teamcity/agent/steam-sdk/kaniko-build.py b/linux/ecosystem/teamcity/agent/steam-sdk/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/teamcity/agent/steam-sdk/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/teamcity/agent/steam-sdk/requirements.txt b/linux/ecosystem/teamcity/agent/steam-sdk/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/teamcity/agent/steam-sdk/requirements.txt +++ b/linux/ecosystem/teamcity/agent/steam-sdk/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.4.1.3669/ad/Makefile b/linux/ecosystem/testrail/5.4.1.3669/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.4.1.3669/ad/Makefile +++ b/linux/ecosystem/testrail/5.4.1.3669/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.4.1.3669/ad/kaniko-build.py b/linux/ecosystem/testrail/5.4.1.3669/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.4.1.3669/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.4.1.3669/ad/requirements.txt b/linux/ecosystem/testrail/5.4.1.3669/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.4.1.3669/ad/requirements.txt +++ b/linux/ecosystem/testrail/5.4.1.3669/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.4.1.3669/ldap/Makefile b/linux/ecosystem/testrail/5.4.1.3669/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.4.1.3669/ldap/Makefile +++ b/linux/ecosystem/testrail/5.4.1.3669/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.4.1.3669/ldap/kaniko-build.py b/linux/ecosystem/testrail/5.4.1.3669/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.4.1.3669/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.4.1.3669/ldap/requirements.txt b/linux/ecosystem/testrail/5.4.1.3669/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.4.1.3669/ldap/requirements.txt +++ b/linux/ecosystem/testrail/5.4.1.3669/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.4.1.3669/main/Makefile b/linux/ecosystem/testrail/5.4.1.3669/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.4.1.3669/main/Makefile +++ b/linux/ecosystem/testrail/5.4.1.3669/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.4.1.3669/main/kaniko-build.py b/linux/ecosystem/testrail/5.4.1.3669/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.4.1.3669/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.4.1.3669/main/requirements.txt b/linux/ecosystem/testrail/5.4.1.3669/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.4.1.3669/main/requirements.txt +++ b/linux/ecosystem/testrail/5.4.1.3669/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.5.0.3727/ad/Makefile b/linux/ecosystem/testrail/5.5.0.3727/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.5.0.3727/ad/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3727/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.5.0.3727/ad/kaniko-build.py b/linux/ecosystem/testrail/5.5.0.3727/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.5.0.3727/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.5.0.3727/ad/requirements.txt b/linux/ecosystem/testrail/5.5.0.3727/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.5.0.3727/ad/requirements.txt +++ b/linux/ecosystem/testrail/5.5.0.3727/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.5.0.3727/ldap/Makefile b/linux/ecosystem/testrail/5.5.0.3727/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.5.0.3727/ldap/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3727/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.5.0.3727/ldap/kaniko-build.py b/linux/ecosystem/testrail/5.5.0.3727/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.5.0.3727/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.5.0.3727/ldap/requirements.txt b/linux/ecosystem/testrail/5.5.0.3727/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.5.0.3727/ldap/requirements.txt +++ b/linux/ecosystem/testrail/5.5.0.3727/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.5.0.3727/main/Makefile b/linux/ecosystem/testrail/5.5.0.3727/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.5.0.3727/main/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3727/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.5.0.3727/main/kaniko-build.py b/linux/ecosystem/testrail/5.5.0.3727/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.5.0.3727/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.5.0.3727/main/requirements.txt b/linux/ecosystem/testrail/5.5.0.3727/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.5.0.3727/main/requirements.txt +++ b/linux/ecosystem/testrail/5.5.0.3727/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.5.0.3731/ad/Makefile b/linux/ecosystem/testrail/5.5.0.3731/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.5.0.3731/ad/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3731/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.5.0.3731/ad/kaniko-build.py b/linux/ecosystem/testrail/5.5.0.3731/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.5.0.3731/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.5.0.3731/ad/requirements.txt b/linux/ecosystem/testrail/5.5.0.3731/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.5.0.3731/ad/requirements.txt +++ b/linux/ecosystem/testrail/5.5.0.3731/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.5.0.3731/ldap/Makefile b/linux/ecosystem/testrail/5.5.0.3731/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.5.0.3731/ldap/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3731/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.5.0.3731/ldap/kaniko-build.py b/linux/ecosystem/testrail/5.5.0.3731/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.5.0.3731/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.5.0.3731/ldap/requirements.txt b/linux/ecosystem/testrail/5.5.0.3731/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.5.0.3731/ldap/requirements.txt +++ b/linux/ecosystem/testrail/5.5.0.3731/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.5.0.3731/main/Makefile b/linux/ecosystem/testrail/5.5.0.3731/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.5.0.3731/main/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3731/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.5.0.3731/main/kaniko-build.py b/linux/ecosystem/testrail/5.5.0.3731/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.5.0.3731/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.5.0.3731/main/requirements.txt b/linux/ecosystem/testrail/5.5.0.3731/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.5.0.3731/main/requirements.txt +++ b/linux/ecosystem/testrail/5.5.0.3731/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.5.0.3735/ad/Makefile b/linux/ecosystem/testrail/5.5.0.3735/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.5.0.3735/ad/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3735/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.5.0.3735/ad/kaniko-build.py b/linux/ecosystem/testrail/5.5.0.3735/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.5.0.3735/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.5.0.3735/ad/requirements.txt b/linux/ecosystem/testrail/5.5.0.3735/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.5.0.3735/ad/requirements.txt +++ b/linux/ecosystem/testrail/5.5.0.3735/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.5.0.3735/ldap/Makefile b/linux/ecosystem/testrail/5.5.0.3735/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.5.0.3735/ldap/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3735/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.5.0.3735/ldap/kaniko-build.py b/linux/ecosystem/testrail/5.5.0.3735/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.5.0.3735/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.5.0.3735/ldap/requirements.txt b/linux/ecosystem/testrail/5.5.0.3735/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.5.0.3735/ldap/requirements.txt +++ b/linux/ecosystem/testrail/5.5.0.3735/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.5.0.3735/main/Makefile b/linux/ecosystem/testrail/5.5.0.3735/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.5.0.3735/main/Makefile +++ b/linux/ecosystem/testrail/5.5.0.3735/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.5.0.3735/main/kaniko-build.py b/linux/ecosystem/testrail/5.5.0.3735/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.5.0.3735/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.5.0.3735/main/requirements.txt b/linux/ecosystem/testrail/5.5.0.3735/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.5.0.3735/main/requirements.txt +++ b/linux/ecosystem/testrail/5.5.0.3735/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.5.1.3746/ad/Makefile b/linux/ecosystem/testrail/5.5.1.3746/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.5.1.3746/ad/Makefile +++ b/linux/ecosystem/testrail/5.5.1.3746/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.5.1.3746/ad/kaniko-build.py b/linux/ecosystem/testrail/5.5.1.3746/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.5.1.3746/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.5.1.3746/ad/requirements.txt b/linux/ecosystem/testrail/5.5.1.3746/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.5.1.3746/ad/requirements.txt +++ b/linux/ecosystem/testrail/5.5.1.3746/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.5.1.3746/ldap/Makefile b/linux/ecosystem/testrail/5.5.1.3746/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.5.1.3746/ldap/Makefile +++ b/linux/ecosystem/testrail/5.5.1.3746/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.5.1.3746/ldap/kaniko-build.py b/linux/ecosystem/testrail/5.5.1.3746/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.5.1.3746/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.5.1.3746/ldap/requirements.txt b/linux/ecosystem/testrail/5.5.1.3746/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.5.1.3746/ldap/requirements.txt +++ b/linux/ecosystem/testrail/5.5.1.3746/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.5.1.3746/main/Makefile b/linux/ecosystem/testrail/5.5.1.3746/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.5.1.3746/main/Makefile +++ b/linux/ecosystem/testrail/5.5.1.3746/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.5.1.3746/main/kaniko-build.py b/linux/ecosystem/testrail/5.5.1.3746/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.5.1.3746/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.5.1.3746/main/requirements.txt b/linux/ecosystem/testrail/5.5.1.3746/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.5.1.3746/main/requirements.txt +++ b/linux/ecosystem/testrail/5.5.1.3746/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.6.0.3853/ad/Makefile b/linux/ecosystem/testrail/5.6.0.3853/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.6.0.3853/ad/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3853/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.6.0.3853/ad/kaniko-build.py b/linux/ecosystem/testrail/5.6.0.3853/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.6.0.3853/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.6.0.3853/ad/requirements.txt b/linux/ecosystem/testrail/5.6.0.3853/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.6.0.3853/ad/requirements.txt +++ b/linux/ecosystem/testrail/5.6.0.3853/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.6.0.3853/ldap/Makefile b/linux/ecosystem/testrail/5.6.0.3853/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.6.0.3853/ldap/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3853/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.6.0.3853/ldap/kaniko-build.py b/linux/ecosystem/testrail/5.6.0.3853/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.6.0.3853/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.6.0.3853/ldap/requirements.txt b/linux/ecosystem/testrail/5.6.0.3853/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.6.0.3853/ldap/requirements.txt +++ b/linux/ecosystem/testrail/5.6.0.3853/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.6.0.3853/main/Makefile b/linux/ecosystem/testrail/5.6.0.3853/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.6.0.3853/main/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3853/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.6.0.3853/main/kaniko-build.py b/linux/ecosystem/testrail/5.6.0.3853/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.6.0.3853/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.6.0.3853/main/requirements.txt b/linux/ecosystem/testrail/5.6.0.3853/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.6.0.3853/main/requirements.txt +++ b/linux/ecosystem/testrail/5.6.0.3853/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.6.0.3856/ad/Makefile b/linux/ecosystem/testrail/5.6.0.3856/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.6.0.3856/ad/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3856/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.6.0.3856/ad/kaniko-build.py b/linux/ecosystem/testrail/5.6.0.3856/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.6.0.3856/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.6.0.3856/ad/requirements.txt b/linux/ecosystem/testrail/5.6.0.3856/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.6.0.3856/ad/requirements.txt +++ b/linux/ecosystem/testrail/5.6.0.3856/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.6.0.3856/ldap/Makefile b/linux/ecosystem/testrail/5.6.0.3856/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.6.0.3856/ldap/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3856/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.6.0.3856/ldap/kaniko-build.py b/linux/ecosystem/testrail/5.6.0.3856/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.6.0.3856/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.6.0.3856/ldap/requirements.txt b/linux/ecosystem/testrail/5.6.0.3856/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.6.0.3856/ldap/requirements.txt +++ b/linux/ecosystem/testrail/5.6.0.3856/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.6.0.3856/main/Makefile b/linux/ecosystem/testrail/5.6.0.3856/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.6.0.3856/main/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3856/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.6.0.3856/main/kaniko-build.py b/linux/ecosystem/testrail/5.6.0.3856/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.6.0.3856/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.6.0.3856/main/requirements.txt b/linux/ecosystem/testrail/5.6.0.3856/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.6.0.3856/main/requirements.txt +++ b/linux/ecosystem/testrail/5.6.0.3856/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.6.0.3861/ad/Makefile b/linux/ecosystem/testrail/5.6.0.3861/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.6.0.3861/ad/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3861/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.6.0.3861/ad/kaniko-build.py b/linux/ecosystem/testrail/5.6.0.3861/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.6.0.3861/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.6.0.3861/ad/requirements.txt b/linux/ecosystem/testrail/5.6.0.3861/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.6.0.3861/ad/requirements.txt +++ b/linux/ecosystem/testrail/5.6.0.3861/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.6.0.3861/ldap/Makefile b/linux/ecosystem/testrail/5.6.0.3861/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.6.0.3861/ldap/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3861/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.6.0.3861/ldap/kaniko-build.py b/linux/ecosystem/testrail/5.6.0.3861/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.6.0.3861/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.6.0.3861/ldap/requirements.txt b/linux/ecosystem/testrail/5.6.0.3861/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.6.0.3861/ldap/requirements.txt +++ b/linux/ecosystem/testrail/5.6.0.3861/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.6.0.3861/main/Makefile b/linux/ecosystem/testrail/5.6.0.3861/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.6.0.3861/main/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3861/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.6.0.3861/main/kaniko-build.py b/linux/ecosystem/testrail/5.6.0.3861/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.6.0.3861/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.6.0.3861/main/requirements.txt b/linux/ecosystem/testrail/5.6.0.3861/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.6.0.3861/main/requirements.txt +++ b/linux/ecosystem/testrail/5.6.0.3861/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.6.0.3862/ad/Makefile b/linux/ecosystem/testrail/5.6.0.3862/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.6.0.3862/ad/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3862/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.6.0.3862/ad/kaniko-build.py b/linux/ecosystem/testrail/5.6.0.3862/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.6.0.3862/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.6.0.3862/ad/requirements.txt b/linux/ecosystem/testrail/5.6.0.3862/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.6.0.3862/ad/requirements.txt +++ b/linux/ecosystem/testrail/5.6.0.3862/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.6.0.3862/ldap/Makefile b/linux/ecosystem/testrail/5.6.0.3862/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.6.0.3862/ldap/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3862/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.6.0.3862/ldap/kaniko-build.py b/linux/ecosystem/testrail/5.6.0.3862/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.6.0.3862/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.6.0.3862/ldap/requirements.txt b/linux/ecosystem/testrail/5.6.0.3862/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.6.0.3862/ldap/requirements.txt +++ b/linux/ecosystem/testrail/5.6.0.3862/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.6.0.3862/main/Makefile b/linux/ecosystem/testrail/5.6.0.3862/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.6.0.3862/main/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3862/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.6.0.3862/main/kaniko-build.py b/linux/ecosystem/testrail/5.6.0.3862/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.6.0.3862/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.6.0.3862/main/requirements.txt b/linux/ecosystem/testrail/5.6.0.3862/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.6.0.3862/main/requirements.txt +++ b/linux/ecosystem/testrail/5.6.0.3862/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.6.0.3865/ad/Makefile b/linux/ecosystem/testrail/5.6.0.3865/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.6.0.3865/ad/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3865/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.6.0.3865/ad/kaniko-build.py b/linux/ecosystem/testrail/5.6.0.3865/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.6.0.3865/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.6.0.3865/ad/requirements.txt b/linux/ecosystem/testrail/5.6.0.3865/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.6.0.3865/ad/requirements.txt +++ b/linux/ecosystem/testrail/5.6.0.3865/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.6.0.3865/ldap/Makefile b/linux/ecosystem/testrail/5.6.0.3865/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.6.0.3865/ldap/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3865/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.6.0.3865/ldap/kaniko-build.py b/linux/ecosystem/testrail/5.6.0.3865/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.6.0.3865/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.6.0.3865/ldap/requirements.txt b/linux/ecosystem/testrail/5.6.0.3865/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.6.0.3865/ldap/requirements.txt +++ b/linux/ecosystem/testrail/5.6.0.3865/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.6.0.3865/main/Makefile b/linux/ecosystem/testrail/5.6.0.3865/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.6.0.3865/main/Makefile +++ b/linux/ecosystem/testrail/5.6.0.3865/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.6.0.3865/main/kaniko-build.py b/linux/ecosystem/testrail/5.6.0.3865/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.6.0.3865/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.6.0.3865/main/requirements.txt b/linux/ecosystem/testrail/5.6.0.3865/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.6.0.3865/main/requirements.txt +++ b/linux/ecosystem/testrail/5.6.0.3865/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.7.0.3938/ad/Makefile b/linux/ecosystem/testrail/5.7.0.3938/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.7.0.3938/ad/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3938/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.7.0.3938/ad/kaniko-build.py b/linux/ecosystem/testrail/5.7.0.3938/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.7.0.3938/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.7.0.3938/ad/requirements.txt b/linux/ecosystem/testrail/5.7.0.3938/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.7.0.3938/ad/requirements.txt +++ b/linux/ecosystem/testrail/5.7.0.3938/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.7.0.3938/ldap/Makefile b/linux/ecosystem/testrail/5.7.0.3938/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.7.0.3938/ldap/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3938/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.7.0.3938/ldap/kaniko-build.py b/linux/ecosystem/testrail/5.7.0.3938/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.7.0.3938/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.7.0.3938/ldap/requirements.txt b/linux/ecosystem/testrail/5.7.0.3938/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.7.0.3938/ldap/requirements.txt +++ b/linux/ecosystem/testrail/5.7.0.3938/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.7.0.3938/main/Makefile b/linux/ecosystem/testrail/5.7.0.3938/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.7.0.3938/main/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3938/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.7.0.3938/main/kaniko-build.py b/linux/ecosystem/testrail/5.7.0.3938/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.7.0.3938/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.7.0.3938/main/requirements.txt b/linux/ecosystem/testrail/5.7.0.3938/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.7.0.3938/main/requirements.txt +++ b/linux/ecosystem/testrail/5.7.0.3938/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.7.0.3942/ad/Makefile b/linux/ecosystem/testrail/5.7.0.3942/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.7.0.3942/ad/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3942/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.7.0.3942/ad/kaniko-build.py b/linux/ecosystem/testrail/5.7.0.3942/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.7.0.3942/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.7.0.3942/ad/requirements.txt b/linux/ecosystem/testrail/5.7.0.3942/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.7.0.3942/ad/requirements.txt +++ b/linux/ecosystem/testrail/5.7.0.3942/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.7.0.3942/ldap/Makefile b/linux/ecosystem/testrail/5.7.0.3942/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.7.0.3942/ldap/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3942/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.7.0.3942/ldap/kaniko-build.py b/linux/ecosystem/testrail/5.7.0.3942/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.7.0.3942/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.7.0.3942/ldap/requirements.txt b/linux/ecosystem/testrail/5.7.0.3942/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.7.0.3942/ldap/requirements.txt +++ b/linux/ecosystem/testrail/5.7.0.3942/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.7.0.3942/main/Makefile b/linux/ecosystem/testrail/5.7.0.3942/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.7.0.3942/main/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3942/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.7.0.3942/main/kaniko-build.py b/linux/ecosystem/testrail/5.7.0.3942/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.7.0.3942/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.7.0.3942/main/requirements.txt b/linux/ecosystem/testrail/5.7.0.3942/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.7.0.3942/main/requirements.txt +++ b/linux/ecosystem/testrail/5.7.0.3942/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.7.0.3951/ad/Makefile b/linux/ecosystem/testrail/5.7.0.3951/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.7.0.3951/ad/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3951/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.7.0.3951/ad/kaniko-build.py b/linux/ecosystem/testrail/5.7.0.3951/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.7.0.3951/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.7.0.3951/ad/requirements.txt b/linux/ecosystem/testrail/5.7.0.3951/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.7.0.3951/ad/requirements.txt +++ b/linux/ecosystem/testrail/5.7.0.3951/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.7.0.3951/ldap/Makefile b/linux/ecosystem/testrail/5.7.0.3951/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.7.0.3951/ldap/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3951/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.7.0.3951/ldap/kaniko-build.py b/linux/ecosystem/testrail/5.7.0.3951/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.7.0.3951/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.7.0.3951/ldap/requirements.txt b/linux/ecosystem/testrail/5.7.0.3951/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.7.0.3951/ldap/requirements.txt +++ b/linux/ecosystem/testrail/5.7.0.3951/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.7.0.3951/main/Makefile b/linux/ecosystem/testrail/5.7.0.3951/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.7.0.3951/main/Makefile +++ b/linux/ecosystem/testrail/5.7.0.3951/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.7.0.3951/main/kaniko-build.py b/linux/ecosystem/testrail/5.7.0.3951/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.7.0.3951/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.7.0.3951/main/requirements.txt b/linux/ecosystem/testrail/5.7.0.3951/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.7.0.3951/main/requirements.txt +++ b/linux/ecosystem/testrail/5.7.0.3951/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.7.1.4026/ad/Makefile b/linux/ecosystem/testrail/5.7.1.4026/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.7.1.4026/ad/Makefile +++ b/linux/ecosystem/testrail/5.7.1.4026/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.7.1.4026/ad/kaniko-build.py b/linux/ecosystem/testrail/5.7.1.4026/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.7.1.4026/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.7.1.4026/ad/requirements.txt b/linux/ecosystem/testrail/5.7.1.4026/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.7.1.4026/ad/requirements.txt +++ b/linux/ecosystem/testrail/5.7.1.4026/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.7.1.4026/ldap/Makefile b/linux/ecosystem/testrail/5.7.1.4026/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.7.1.4026/ldap/Makefile +++ b/linux/ecosystem/testrail/5.7.1.4026/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.7.1.4026/ldap/kaniko-build.py b/linux/ecosystem/testrail/5.7.1.4026/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.7.1.4026/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.7.1.4026/ldap/requirements.txt b/linux/ecosystem/testrail/5.7.1.4026/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.7.1.4026/ldap/requirements.txt +++ b/linux/ecosystem/testrail/5.7.1.4026/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.7.1.4026/main/Makefile b/linux/ecosystem/testrail/5.7.1.4026/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.7.1.4026/main/Makefile +++ b/linux/ecosystem/testrail/5.7.1.4026/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.7.1.4026/main/kaniko-build.py b/linux/ecosystem/testrail/5.7.1.4026/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.7.1.4026/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.7.1.4026/main/requirements.txt b/linux/ecosystem/testrail/5.7.1.4026/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.7.1.4026/main/requirements.txt +++ b/linux/ecosystem/testrail/5.7.1.4026/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.7.1.4028/ad/Makefile b/linux/ecosystem/testrail/5.7.1.4028/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.7.1.4028/ad/Makefile +++ b/linux/ecosystem/testrail/5.7.1.4028/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.7.1.4028/ad/kaniko-build.py b/linux/ecosystem/testrail/5.7.1.4028/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.7.1.4028/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.7.1.4028/ad/requirements.txt b/linux/ecosystem/testrail/5.7.1.4028/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.7.1.4028/ad/requirements.txt +++ b/linux/ecosystem/testrail/5.7.1.4028/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.7.1.4028/ldap/Makefile b/linux/ecosystem/testrail/5.7.1.4028/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.7.1.4028/ldap/Makefile +++ b/linux/ecosystem/testrail/5.7.1.4028/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.7.1.4028/ldap/kaniko-build.py b/linux/ecosystem/testrail/5.7.1.4028/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.7.1.4028/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.7.1.4028/ldap/requirements.txt b/linux/ecosystem/testrail/5.7.1.4028/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.7.1.4028/ldap/requirements.txt +++ b/linux/ecosystem/testrail/5.7.1.4028/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/5.7.1.4028/main/Makefile b/linux/ecosystem/testrail/5.7.1.4028/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/5.7.1.4028/main/Makefile +++ b/linux/ecosystem/testrail/5.7.1.4028/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/5.7.1.4028/main/kaniko-build.py b/linux/ecosystem/testrail/5.7.1.4028/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/5.7.1.4028/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/5.7.1.4028/main/requirements.txt b/linux/ecosystem/testrail/5.7.1.4028/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/5.7.1.4028/main/requirements.txt +++ b/linux/ecosystem/testrail/5.7.1.4028/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.0.0.4140/ad/Makefile b/linux/ecosystem/testrail/6.0.0.4140/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.0.0.4140/ad/Makefile +++ b/linux/ecosystem/testrail/6.0.0.4140/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.0.0.4140/ad/kaniko-build.py b/linux/ecosystem/testrail/6.0.0.4140/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.0.0.4140/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.0.0.4140/ad/requirements.txt b/linux/ecosystem/testrail/6.0.0.4140/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.0.0.4140/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.0.0.4140/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.0.0.4140/ldap/Makefile b/linux/ecosystem/testrail/6.0.0.4140/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.0.0.4140/ldap/Makefile +++ b/linux/ecosystem/testrail/6.0.0.4140/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.0.0.4140/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.0.0.4140/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.0.0.4140/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.0.0.4140/ldap/requirements.txt b/linux/ecosystem/testrail/6.0.0.4140/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.0.0.4140/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.0.0.4140/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.0.0.4140/main/Makefile b/linux/ecosystem/testrail/6.0.0.4140/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.0.0.4140/main/Makefile +++ b/linux/ecosystem/testrail/6.0.0.4140/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.0.0.4140/main/kaniko-build.py b/linux/ecosystem/testrail/6.0.0.4140/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.0.0.4140/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.0.0.4140/main/requirements.txt b/linux/ecosystem/testrail/6.0.0.4140/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.0.0.4140/main/requirements.txt +++ b/linux/ecosystem/testrail/6.0.0.4140/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.0.1.4163/ad/Makefile b/linux/ecosystem/testrail/6.0.1.4163/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.0.1.4163/ad/Makefile +++ b/linux/ecosystem/testrail/6.0.1.4163/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.0.1.4163/ad/kaniko-build.py b/linux/ecosystem/testrail/6.0.1.4163/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.0.1.4163/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.0.1.4163/ad/requirements.txt b/linux/ecosystem/testrail/6.0.1.4163/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.0.1.4163/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.0.1.4163/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.0.1.4163/ldap/Makefile b/linux/ecosystem/testrail/6.0.1.4163/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.0.1.4163/ldap/Makefile +++ b/linux/ecosystem/testrail/6.0.1.4163/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.0.1.4163/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.0.1.4163/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.0.1.4163/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.0.1.4163/ldap/requirements.txt b/linux/ecosystem/testrail/6.0.1.4163/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.0.1.4163/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.0.1.4163/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.0.1.4163/main/Makefile b/linux/ecosystem/testrail/6.0.1.4163/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.0.1.4163/main/Makefile +++ b/linux/ecosystem/testrail/6.0.1.4163/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.0.1.4163/main/kaniko-build.py b/linux/ecosystem/testrail/6.0.1.4163/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.0.1.4163/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.0.1.4163/main/requirements.txt b/linux/ecosystem/testrail/6.0.1.4163/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.0.1.4163/main/requirements.txt +++ b/linux/ecosystem/testrail/6.0.1.4163/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.1.0.4367/ad/Makefile b/linux/ecosystem/testrail/6.1.0.4367/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.1.0.4367/ad/Makefile +++ b/linux/ecosystem/testrail/6.1.0.4367/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.1.0.4367/ad/kaniko-build.py b/linux/ecosystem/testrail/6.1.0.4367/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.1.0.4367/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.1.0.4367/ad/requirements.txt b/linux/ecosystem/testrail/6.1.0.4367/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.1.0.4367/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.1.0.4367/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.1.0.4367/ldap/Makefile b/linux/ecosystem/testrail/6.1.0.4367/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.1.0.4367/ldap/Makefile +++ b/linux/ecosystem/testrail/6.1.0.4367/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.1.0.4367/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.1.0.4367/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.1.0.4367/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.1.0.4367/ldap/requirements.txt b/linux/ecosystem/testrail/6.1.0.4367/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.1.0.4367/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.1.0.4367/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.1.0.4367/main/Makefile b/linux/ecosystem/testrail/6.1.0.4367/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.1.0.4367/main/Makefile +++ b/linux/ecosystem/testrail/6.1.0.4367/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.1.0.4367/main/kaniko-build.py b/linux/ecosystem/testrail/6.1.0.4367/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.1.0.4367/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.1.0.4367/main/requirements.txt b/linux/ecosystem/testrail/6.1.0.4367/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.1.0.4367/main/requirements.txt +++ b/linux/ecosystem/testrail/6.1.0.4367/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.1.0.4369/ad/Makefile b/linux/ecosystem/testrail/6.1.0.4369/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.1.0.4369/ad/Makefile +++ b/linux/ecosystem/testrail/6.1.0.4369/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.1.0.4369/ad/kaniko-build.py b/linux/ecosystem/testrail/6.1.0.4369/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.1.0.4369/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.1.0.4369/ad/requirements.txt b/linux/ecosystem/testrail/6.1.0.4369/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.1.0.4369/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.1.0.4369/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.1.0.4369/ldap/Makefile b/linux/ecosystem/testrail/6.1.0.4369/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.1.0.4369/ldap/Makefile +++ b/linux/ecosystem/testrail/6.1.0.4369/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.1.0.4369/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.1.0.4369/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.1.0.4369/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.1.0.4369/ldap/requirements.txt b/linux/ecosystem/testrail/6.1.0.4369/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.1.0.4369/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.1.0.4369/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.1.0.4369/main/Makefile b/linux/ecosystem/testrail/6.1.0.4369/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.1.0.4369/main/Makefile +++ b/linux/ecosystem/testrail/6.1.0.4369/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.1.0.4369/main/kaniko-build.py b/linux/ecosystem/testrail/6.1.0.4369/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.1.0.4369/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.1.0.4369/main/requirements.txt b/linux/ecosystem/testrail/6.1.0.4369/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.1.0.4369/main/requirements.txt +++ b/linux/ecosystem/testrail/6.1.0.4369/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.1.1.1020/ad/Makefile b/linux/ecosystem/testrail/6.1.1.1020/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.1.1.1020/ad/Makefile +++ b/linux/ecosystem/testrail/6.1.1.1020/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.1.1.1020/ad/kaniko-build.py b/linux/ecosystem/testrail/6.1.1.1020/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.1.1.1020/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.1.1.1020/ad/requirements.txt b/linux/ecosystem/testrail/6.1.1.1020/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.1.1.1020/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.1.1.1020/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.1.1.1020/ldap/Makefile b/linux/ecosystem/testrail/6.1.1.1020/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.1.1.1020/ldap/Makefile +++ b/linux/ecosystem/testrail/6.1.1.1020/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.1.1.1020/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.1.1.1020/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.1.1.1020/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.1.1.1020/ldap/requirements.txt b/linux/ecosystem/testrail/6.1.1.1020/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.1.1.1020/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.1.1.1020/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.1.1.1020/main/Makefile b/linux/ecosystem/testrail/6.1.1.1020/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.1.1.1020/main/Makefile +++ b/linux/ecosystem/testrail/6.1.1.1020/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.1.1.1020/main/kaniko-build.py b/linux/ecosystem/testrail/6.1.1.1020/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.1.1.1020/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.1.1.1020/main/requirements.txt b/linux/ecosystem/testrail/6.1.1.1020/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.1.1.1020/main/requirements.txt +++ b/linux/ecosystem/testrail/6.1.1.1020/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.1.1.1021/ad/Makefile b/linux/ecosystem/testrail/6.1.1.1021/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.1.1.1021/ad/Makefile +++ b/linux/ecosystem/testrail/6.1.1.1021/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.1.1.1021/ad/kaniko-build.py b/linux/ecosystem/testrail/6.1.1.1021/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.1.1.1021/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.1.1.1021/ad/requirements.txt b/linux/ecosystem/testrail/6.1.1.1021/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.1.1.1021/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.1.1.1021/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.1.1.1021/ldap/Makefile b/linux/ecosystem/testrail/6.1.1.1021/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.1.1.1021/ldap/Makefile +++ b/linux/ecosystem/testrail/6.1.1.1021/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.1.1.1021/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.1.1.1021/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.1.1.1021/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.1.1.1021/ldap/requirements.txt b/linux/ecosystem/testrail/6.1.1.1021/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.1.1.1021/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.1.1.1021/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.1.1.1021/main/Makefile b/linux/ecosystem/testrail/6.1.1.1021/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.1.1.1021/main/Makefile +++ b/linux/ecosystem/testrail/6.1.1.1021/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.1.1.1021/main/kaniko-build.py b/linux/ecosystem/testrail/6.1.1.1021/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.1.1.1021/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.1.1.1021/main/requirements.txt b/linux/ecosystem/testrail/6.1.1.1021/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.1.1.1021/main/requirements.txt +++ b/linux/ecosystem/testrail/6.1.1.1021/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.2.0.1085/ad/Makefile b/linux/ecosystem/testrail/6.2.0.1085/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.2.0.1085/ad/Makefile +++ b/linux/ecosystem/testrail/6.2.0.1085/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.2.0.1085/ad/kaniko-build.py b/linux/ecosystem/testrail/6.2.0.1085/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.2.0.1085/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.2.0.1085/ad/requirements.txt b/linux/ecosystem/testrail/6.2.0.1085/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.2.0.1085/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.2.0.1085/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.2.0.1085/ldap/Makefile b/linux/ecosystem/testrail/6.2.0.1085/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.2.0.1085/ldap/Makefile +++ b/linux/ecosystem/testrail/6.2.0.1085/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.2.0.1085/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.2.0.1085/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.2.0.1085/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.2.0.1085/ldap/requirements.txt b/linux/ecosystem/testrail/6.2.0.1085/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.2.0.1085/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.2.0.1085/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.2.0.1085/main/Makefile b/linux/ecosystem/testrail/6.2.0.1085/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.2.0.1085/main/Makefile +++ b/linux/ecosystem/testrail/6.2.0.1085/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.2.0.1085/main/kaniko-build.py b/linux/ecosystem/testrail/6.2.0.1085/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.2.0.1085/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.2.0.1085/main/requirements.txt b/linux/ecosystem/testrail/6.2.0.1085/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.2.0.1085/main/requirements.txt +++ b/linux/ecosystem/testrail/6.2.0.1085/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.2.1.1003/ad/Makefile b/linux/ecosystem/testrail/6.2.1.1003/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.2.1.1003/ad/Makefile +++ b/linux/ecosystem/testrail/6.2.1.1003/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.2.1.1003/ad/kaniko-build.py b/linux/ecosystem/testrail/6.2.1.1003/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.2.1.1003/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.2.1.1003/ad/requirements.txt b/linux/ecosystem/testrail/6.2.1.1003/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.2.1.1003/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.2.1.1003/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.2.1.1003/ldap/Makefile b/linux/ecosystem/testrail/6.2.1.1003/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.2.1.1003/ldap/Makefile +++ b/linux/ecosystem/testrail/6.2.1.1003/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.2.1.1003/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.2.1.1003/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.2.1.1003/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.2.1.1003/ldap/requirements.txt b/linux/ecosystem/testrail/6.2.1.1003/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.2.1.1003/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.2.1.1003/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.2.1.1003/main/Makefile b/linux/ecosystem/testrail/6.2.1.1003/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.2.1.1003/main/Makefile +++ b/linux/ecosystem/testrail/6.2.1.1003/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.2.1.1003/main/kaniko-build.py b/linux/ecosystem/testrail/6.2.1.1003/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.2.1.1003/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.2.1.1003/main/requirements.txt b/linux/ecosystem/testrail/6.2.1.1003/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.2.1.1003/main/requirements.txt +++ b/linux/ecosystem/testrail/6.2.1.1003/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.2.1.1005/ad/Makefile b/linux/ecosystem/testrail/6.2.1.1005/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.2.1.1005/ad/Makefile +++ b/linux/ecosystem/testrail/6.2.1.1005/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.2.1.1005/ad/kaniko-build.py b/linux/ecosystem/testrail/6.2.1.1005/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.2.1.1005/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.2.1.1005/ad/requirements.txt b/linux/ecosystem/testrail/6.2.1.1005/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.2.1.1005/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.2.1.1005/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.2.1.1005/ldap/Makefile b/linux/ecosystem/testrail/6.2.1.1005/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.2.1.1005/ldap/Makefile +++ b/linux/ecosystem/testrail/6.2.1.1005/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.2.1.1005/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.2.1.1005/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.2.1.1005/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.2.1.1005/ldap/requirements.txt b/linux/ecosystem/testrail/6.2.1.1005/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.2.1.1005/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.2.1.1005/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.2.1.1005/main/Makefile b/linux/ecosystem/testrail/6.2.1.1005/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.2.1.1005/main/Makefile +++ b/linux/ecosystem/testrail/6.2.1.1005/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.2.1.1005/main/kaniko-build.py b/linux/ecosystem/testrail/6.2.1.1005/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.2.1.1005/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.2.1.1005/main/requirements.txt b/linux/ecosystem/testrail/6.2.1.1005/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.2.1.1005/main/requirements.txt +++ b/linux/ecosystem/testrail/6.2.1.1005/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.2.2.1107/ad/Makefile b/linux/ecosystem/testrail/6.2.2.1107/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.2.2.1107/ad/Makefile +++ b/linux/ecosystem/testrail/6.2.2.1107/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.2.2.1107/ad/kaniko-build.py b/linux/ecosystem/testrail/6.2.2.1107/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.2.2.1107/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.2.2.1107/ad/requirements.txt b/linux/ecosystem/testrail/6.2.2.1107/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.2.2.1107/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.2.2.1107/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.2.2.1107/ldap/Makefile b/linux/ecosystem/testrail/6.2.2.1107/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.2.2.1107/ldap/Makefile +++ b/linux/ecosystem/testrail/6.2.2.1107/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.2.2.1107/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.2.2.1107/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.2.2.1107/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.2.2.1107/ldap/requirements.txt b/linux/ecosystem/testrail/6.2.2.1107/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.2.2.1107/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.2.2.1107/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.2.2.1107/main/Makefile b/linux/ecosystem/testrail/6.2.2.1107/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.2.2.1107/main/Makefile +++ b/linux/ecosystem/testrail/6.2.2.1107/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.2.2.1107/main/kaniko-build.py b/linux/ecosystem/testrail/6.2.2.1107/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.2.2.1107/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.2.2.1107/main/requirements.txt b/linux/ecosystem/testrail/6.2.2.1107/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.2.2.1107/main/requirements.txt +++ b/linux/ecosystem/testrail/6.2.2.1107/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.2.3.1114/ad/Makefile b/linux/ecosystem/testrail/6.2.3.1114/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.2.3.1114/ad/Makefile +++ b/linux/ecosystem/testrail/6.2.3.1114/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.2.3.1114/ad/kaniko-build.py b/linux/ecosystem/testrail/6.2.3.1114/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.2.3.1114/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.2.3.1114/ad/requirements.txt b/linux/ecosystem/testrail/6.2.3.1114/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.2.3.1114/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.2.3.1114/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.2.3.1114/ldap/Makefile b/linux/ecosystem/testrail/6.2.3.1114/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.2.3.1114/ldap/Makefile +++ b/linux/ecosystem/testrail/6.2.3.1114/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.2.3.1114/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.2.3.1114/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.2.3.1114/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.2.3.1114/ldap/requirements.txt b/linux/ecosystem/testrail/6.2.3.1114/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.2.3.1114/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.2.3.1114/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.2.3.1114/main/Makefile b/linux/ecosystem/testrail/6.2.3.1114/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.2.3.1114/main/Makefile +++ b/linux/ecosystem/testrail/6.2.3.1114/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.2.3.1114/main/kaniko-build.py b/linux/ecosystem/testrail/6.2.3.1114/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.2.3.1114/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.2.3.1114/main/requirements.txt b/linux/ecosystem/testrail/6.2.3.1114/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.2.3.1114/main/requirements.txt +++ b/linux/ecosystem/testrail/6.2.3.1114/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.3.0.1120/ad/Makefile b/linux/ecosystem/testrail/6.3.0.1120/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.3.0.1120/ad/Makefile +++ b/linux/ecosystem/testrail/6.3.0.1120/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.3.0.1120/ad/kaniko-build.py b/linux/ecosystem/testrail/6.3.0.1120/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.3.0.1120/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.3.0.1120/ad/requirements.txt b/linux/ecosystem/testrail/6.3.0.1120/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.3.0.1120/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.3.0.1120/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.3.0.1120/ldap/Makefile b/linux/ecosystem/testrail/6.3.0.1120/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.3.0.1120/ldap/Makefile +++ b/linux/ecosystem/testrail/6.3.0.1120/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.3.0.1120/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.3.0.1120/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.3.0.1120/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.3.0.1120/ldap/requirements.txt b/linux/ecosystem/testrail/6.3.0.1120/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.3.0.1120/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.3.0.1120/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.3.0.1120/main/Makefile b/linux/ecosystem/testrail/6.3.0.1120/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.3.0.1120/main/Makefile +++ b/linux/ecosystem/testrail/6.3.0.1120/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.3.0.1120/main/kaniko-build.py b/linux/ecosystem/testrail/6.3.0.1120/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.3.0.1120/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.3.0.1120/main/requirements.txt b/linux/ecosystem/testrail/6.3.0.1120/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.3.0.1120/main/requirements.txt +++ b/linux/ecosystem/testrail/6.3.0.1120/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.3.1.1004/ad/Makefile b/linux/ecosystem/testrail/6.3.1.1004/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.3.1.1004/ad/Makefile +++ b/linux/ecosystem/testrail/6.3.1.1004/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.3.1.1004/ad/kaniko-build.py b/linux/ecosystem/testrail/6.3.1.1004/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.3.1.1004/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.3.1.1004/ad/requirements.txt b/linux/ecosystem/testrail/6.3.1.1004/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.3.1.1004/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.3.1.1004/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.3.1.1004/ldap/Makefile b/linux/ecosystem/testrail/6.3.1.1004/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.3.1.1004/ldap/Makefile +++ b/linux/ecosystem/testrail/6.3.1.1004/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.3.1.1004/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.3.1.1004/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.3.1.1004/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.3.1.1004/ldap/requirements.txt b/linux/ecosystem/testrail/6.3.1.1004/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.3.1.1004/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.3.1.1004/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.3.1.1004/main/Makefile b/linux/ecosystem/testrail/6.3.1.1004/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.3.1.1004/main/Makefile +++ b/linux/ecosystem/testrail/6.3.1.1004/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.3.1.1004/main/kaniko-build.py b/linux/ecosystem/testrail/6.3.1.1004/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.3.1.1004/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.3.1.1004/main/requirements.txt b/linux/ecosystem/testrail/6.3.1.1004/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.3.1.1004/main/requirements.txt +++ b/linux/ecosystem/testrail/6.3.1.1004/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.3.1.1006/ad/Makefile b/linux/ecosystem/testrail/6.3.1.1006/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.3.1.1006/ad/Makefile +++ b/linux/ecosystem/testrail/6.3.1.1006/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.3.1.1006/ad/kaniko-build.py b/linux/ecosystem/testrail/6.3.1.1006/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.3.1.1006/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.3.1.1006/ad/requirements.txt b/linux/ecosystem/testrail/6.3.1.1006/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.3.1.1006/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.3.1.1006/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.3.1.1006/ldap/Makefile b/linux/ecosystem/testrail/6.3.1.1006/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.3.1.1006/ldap/Makefile +++ b/linux/ecosystem/testrail/6.3.1.1006/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.3.1.1006/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.3.1.1006/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.3.1.1006/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.3.1.1006/ldap/requirements.txt b/linux/ecosystem/testrail/6.3.1.1006/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.3.1.1006/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.3.1.1006/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.3.1.1006/main/Makefile b/linux/ecosystem/testrail/6.3.1.1006/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.3.1.1006/main/Makefile +++ b/linux/ecosystem/testrail/6.3.1.1006/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.3.1.1006/main/kaniko-build.py b/linux/ecosystem/testrail/6.3.1.1006/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.3.1.1006/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.3.1.1006/main/requirements.txt b/linux/ecosystem/testrail/6.3.1.1006/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.3.1.1006/main/requirements.txt +++ b/linux/ecosystem/testrail/6.3.1.1006/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.4.0.1284/ad/Makefile b/linux/ecosystem/testrail/6.4.0.1284/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.4.0.1284/ad/Makefile +++ b/linux/ecosystem/testrail/6.4.0.1284/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.4.0.1284/ad/kaniko-build.py b/linux/ecosystem/testrail/6.4.0.1284/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.4.0.1284/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.4.0.1284/ad/requirements.txt b/linux/ecosystem/testrail/6.4.0.1284/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.4.0.1284/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.4.0.1284/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.4.0.1284/ldap/Makefile b/linux/ecosystem/testrail/6.4.0.1284/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.4.0.1284/ldap/Makefile +++ b/linux/ecosystem/testrail/6.4.0.1284/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.4.0.1284/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.4.0.1284/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.4.0.1284/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.4.0.1284/ldap/requirements.txt b/linux/ecosystem/testrail/6.4.0.1284/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.4.0.1284/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.4.0.1284/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.4.0.1284/main/Makefile b/linux/ecosystem/testrail/6.4.0.1284/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.4.0.1284/main/Makefile +++ b/linux/ecosystem/testrail/6.4.0.1284/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.4.0.1284/main/kaniko-build.py b/linux/ecosystem/testrail/6.4.0.1284/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.4.0.1284/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.4.0.1284/main/requirements.txt b/linux/ecosystem/testrail/6.4.0.1284/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.4.0.1284/main/requirements.txt +++ b/linux/ecosystem/testrail/6.4.0.1284/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.4.0.1293/ad/Makefile b/linux/ecosystem/testrail/6.4.0.1293/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.4.0.1293/ad/Makefile +++ b/linux/ecosystem/testrail/6.4.0.1293/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.4.0.1293/ad/kaniko-build.py b/linux/ecosystem/testrail/6.4.0.1293/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.4.0.1293/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.4.0.1293/ad/requirements.txt b/linux/ecosystem/testrail/6.4.0.1293/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.4.0.1293/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.4.0.1293/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.4.0.1293/ldap/Makefile b/linux/ecosystem/testrail/6.4.0.1293/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.4.0.1293/ldap/Makefile +++ b/linux/ecosystem/testrail/6.4.0.1293/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.4.0.1293/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.4.0.1293/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.4.0.1293/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.4.0.1293/ldap/requirements.txt b/linux/ecosystem/testrail/6.4.0.1293/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.4.0.1293/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.4.0.1293/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.4.0.1293/main/Makefile b/linux/ecosystem/testrail/6.4.0.1293/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.4.0.1293/main/Makefile +++ b/linux/ecosystem/testrail/6.4.0.1293/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.4.0.1293/main/kaniko-build.py b/linux/ecosystem/testrail/6.4.0.1293/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.4.0.1293/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.4.0.1293/main/requirements.txt b/linux/ecosystem/testrail/6.4.0.1293/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.4.0.1293/main/requirements.txt +++ b/linux/ecosystem/testrail/6.4.0.1293/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.0.1298/ad/Makefile b/linux/ecosystem/testrail/6.5.0.1298/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.0.1298/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.0.1298/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.0.1298/ad/kaniko-build.py b/linux/ecosystem/testrail/6.5.0.1298/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.0.1298/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.0.1298/ad/requirements.txt b/linux/ecosystem/testrail/6.5.0.1298/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.0.1298/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.5.0.1298/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.0.1298/ldap/Makefile b/linux/ecosystem/testrail/6.5.0.1298/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.0.1298/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.0.1298/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.0.1298/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.5.0.1298/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.0.1298/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.0.1298/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.0.1298/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.0.1298/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.5.0.1298/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.0.1298/main/Makefile b/linux/ecosystem/testrail/6.5.0.1298/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.0.1298/main/Makefile +++ b/linux/ecosystem/testrail/6.5.0.1298/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.0.1298/main/kaniko-build.py b/linux/ecosystem/testrail/6.5.0.1298/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.0.1298/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.0.1298/main/requirements.txt b/linux/ecosystem/testrail/6.5.0.1298/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.0.1298/main/requirements.txt +++ b/linux/ecosystem/testrail/6.5.0.1298/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.1.1002/ad/Makefile b/linux/ecosystem/testrail/6.5.1.1002/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.1.1002/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.1.1002/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.1.1002/ad/kaniko-build.py b/linux/ecosystem/testrail/6.5.1.1002/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.1.1002/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.1.1002/ad/requirements.txt b/linux/ecosystem/testrail/6.5.1.1002/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.1.1002/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.5.1.1002/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.1.1002/ldap/Makefile b/linux/ecosystem/testrail/6.5.1.1002/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.1.1002/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.1.1002/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.1.1002/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.5.1.1002/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.1.1002/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.1.1002/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.1.1002/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.1.1002/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.5.1.1002/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.1.1002/main/Makefile b/linux/ecosystem/testrail/6.5.1.1002/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.1.1002/main/Makefile +++ b/linux/ecosystem/testrail/6.5.1.1002/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.1.1002/main/kaniko-build.py b/linux/ecosystem/testrail/6.5.1.1002/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.1.1002/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.1.1002/main/requirements.txt b/linux/ecosystem/testrail/6.5.1.1002/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.1.1002/main/requirements.txt +++ b/linux/ecosystem/testrail/6.5.1.1002/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.3.1001/ad/Makefile b/linux/ecosystem/testrail/6.5.3.1001/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.3.1001/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.3.1001/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.3.1001/ad/kaniko-build.py b/linux/ecosystem/testrail/6.5.3.1001/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.3.1001/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.3.1001/ad/requirements.txt b/linux/ecosystem/testrail/6.5.3.1001/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.3.1001/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.5.3.1001/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.3.1001/ldap/Makefile b/linux/ecosystem/testrail/6.5.3.1001/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.3.1001/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.3.1001/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.3.1001/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.5.3.1001/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.3.1001/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.3.1001/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.3.1001/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.3.1001/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.5.3.1001/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.3.1001/main/Makefile b/linux/ecosystem/testrail/6.5.3.1001/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.3.1001/main/Makefile +++ b/linux/ecosystem/testrail/6.5.3.1001/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.3.1001/main/kaniko-build.py b/linux/ecosystem/testrail/6.5.3.1001/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.3.1001/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.3.1001/main/requirements.txt b/linux/ecosystem/testrail/6.5.3.1001/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.3.1001/main/requirements.txt +++ b/linux/ecosystem/testrail/6.5.3.1001/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.4.1002/ad/Makefile b/linux/ecosystem/testrail/6.5.4.1002/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.4.1002/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.4.1002/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.4.1002/ad/kaniko-build.py b/linux/ecosystem/testrail/6.5.4.1002/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.4.1002/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.4.1002/ad/requirements.txt b/linux/ecosystem/testrail/6.5.4.1002/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.4.1002/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.5.4.1002/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.4.1002/ldap/Makefile b/linux/ecosystem/testrail/6.5.4.1002/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.4.1002/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.4.1002/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.4.1002/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.5.4.1002/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.4.1002/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.4.1002/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.4.1002/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.4.1002/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.5.4.1002/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.4.1002/main/Makefile b/linux/ecosystem/testrail/6.5.4.1002/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.4.1002/main/Makefile +++ b/linux/ecosystem/testrail/6.5.4.1002/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.4.1002/main/kaniko-build.py b/linux/ecosystem/testrail/6.5.4.1002/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.4.1002/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.4.1002/main/requirements.txt b/linux/ecosystem/testrail/6.5.4.1002/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.4.1002/main/requirements.txt +++ b/linux/ecosystem/testrail/6.5.4.1002/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.4.1007/ad/Makefile b/linux/ecosystem/testrail/6.5.4.1007/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.4.1007/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.4.1007/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.4.1007/ad/kaniko-build.py b/linux/ecosystem/testrail/6.5.4.1007/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.4.1007/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.4.1007/ad/requirements.txt b/linux/ecosystem/testrail/6.5.4.1007/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.4.1007/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.5.4.1007/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.4.1007/ldap/Makefile b/linux/ecosystem/testrail/6.5.4.1007/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.4.1007/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.4.1007/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.4.1007/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.5.4.1007/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.4.1007/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.4.1007/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.4.1007/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.4.1007/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.5.4.1007/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.4.1007/main/Makefile b/linux/ecosystem/testrail/6.5.4.1007/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.4.1007/main/Makefile +++ b/linux/ecosystem/testrail/6.5.4.1007/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.4.1007/main/kaniko-build.py b/linux/ecosystem/testrail/6.5.4.1007/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.4.1007/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.4.1007/main/requirements.txt b/linux/ecosystem/testrail/6.5.4.1007/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.4.1007/main/requirements.txt +++ b/linux/ecosystem/testrail/6.5.4.1007/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.5.1009/ad/Makefile b/linux/ecosystem/testrail/6.5.5.1009/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.5.1009/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.5.1009/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.5.1009/ad/kaniko-build.py b/linux/ecosystem/testrail/6.5.5.1009/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.5.1009/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.5.1009/ad/requirements.txt b/linux/ecosystem/testrail/6.5.5.1009/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.5.1009/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.5.5.1009/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.5.1009/ldap/Makefile b/linux/ecosystem/testrail/6.5.5.1009/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.5.1009/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.5.1009/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.5.1009/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.5.5.1009/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.5.1009/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.5.1009/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.5.1009/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.5.1009/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.5.5.1009/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.5.1009/main/Makefile b/linux/ecosystem/testrail/6.5.5.1009/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.5.1009/main/Makefile +++ b/linux/ecosystem/testrail/6.5.5.1009/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.5.1009/main/kaniko-build.py b/linux/ecosystem/testrail/6.5.5.1009/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.5.1009/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.5.1009/main/requirements.txt b/linux/ecosystem/testrail/6.5.5.1009/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.5.1009/main/requirements.txt +++ b/linux/ecosystem/testrail/6.5.5.1009/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.6.1014/ad/Makefile b/linux/ecosystem/testrail/6.5.6.1014/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.6.1014/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.6.1014/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.6.1014/ad/kaniko-build.py b/linux/ecosystem/testrail/6.5.6.1014/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.6.1014/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.6.1014/ad/requirements.txt b/linux/ecosystem/testrail/6.5.6.1014/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.6.1014/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.5.6.1014/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.6.1014/ldap/Makefile b/linux/ecosystem/testrail/6.5.6.1014/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.6.1014/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.6.1014/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.6.1014/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.5.6.1014/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.6.1014/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.6.1014/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.6.1014/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.6.1014/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.5.6.1014/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.6.1014/main/Makefile b/linux/ecosystem/testrail/6.5.6.1014/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.6.1014/main/Makefile +++ b/linux/ecosystem/testrail/6.5.6.1014/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.6.1014/main/kaniko-build.py b/linux/ecosystem/testrail/6.5.6.1014/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.6.1014/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.6.1014/main/requirements.txt b/linux/ecosystem/testrail/6.5.6.1014/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.6.1014/main/requirements.txt +++ b/linux/ecosystem/testrail/6.5.6.1014/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.7.1000/ad/Makefile b/linux/ecosystem/testrail/6.5.7.1000/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.7.1000/ad/Makefile +++ b/linux/ecosystem/testrail/6.5.7.1000/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.7.1000/ad/kaniko-build.py b/linux/ecosystem/testrail/6.5.7.1000/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.7.1000/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.7.1000/ad/requirements.txt b/linux/ecosystem/testrail/6.5.7.1000/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.7.1000/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.5.7.1000/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.7.1000/ldap/Makefile b/linux/ecosystem/testrail/6.5.7.1000/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.7.1000/ldap/Makefile +++ b/linux/ecosystem/testrail/6.5.7.1000/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.7.1000/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.5.7.1000/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.7.1000/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.7.1000/ldap/requirements.txt b/linux/ecosystem/testrail/6.5.7.1000/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.7.1000/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.5.7.1000/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.5.7.1000/main/Makefile b/linux/ecosystem/testrail/6.5.7.1000/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.5.7.1000/main/Makefile +++ b/linux/ecosystem/testrail/6.5.7.1000/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.5.7.1000/main/kaniko-build.py b/linux/ecosystem/testrail/6.5.7.1000/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.5.7.1000/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.5.7.1000/main/requirements.txt b/linux/ecosystem/testrail/6.5.7.1000/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.5.7.1000/main/requirements.txt +++ b/linux/ecosystem/testrail/6.5.7.1000/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.6.0.1156/ad/Makefile b/linux/ecosystem/testrail/6.6.0.1156/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.6.0.1156/ad/Makefile +++ b/linux/ecosystem/testrail/6.6.0.1156/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.6.0.1156/ad/kaniko-build.py b/linux/ecosystem/testrail/6.6.0.1156/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.6.0.1156/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.6.0.1156/ad/requirements.txt b/linux/ecosystem/testrail/6.6.0.1156/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.6.0.1156/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.6.0.1156/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.6.0.1156/ldap/Makefile b/linux/ecosystem/testrail/6.6.0.1156/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.6.0.1156/ldap/Makefile +++ b/linux/ecosystem/testrail/6.6.0.1156/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.6.0.1156/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.6.0.1156/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.6.0.1156/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.6.0.1156/ldap/requirements.txt b/linux/ecosystem/testrail/6.6.0.1156/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.6.0.1156/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.6.0.1156/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.6.0.1156/main/Makefile b/linux/ecosystem/testrail/6.6.0.1156/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.6.0.1156/main/Makefile +++ b/linux/ecosystem/testrail/6.6.0.1156/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.6.0.1156/main/kaniko-build.py b/linux/ecosystem/testrail/6.6.0.1156/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.6.0.1156/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.6.0.1156/main/requirements.txt b/linux/ecosystem/testrail/6.6.0.1156/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.6.0.1156/main/requirements.txt +++ b/linux/ecosystem/testrail/6.6.0.1156/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.6.1.1166/ad/Makefile b/linux/ecosystem/testrail/6.6.1.1166/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.6.1.1166/ad/Makefile +++ b/linux/ecosystem/testrail/6.6.1.1166/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.6.1.1166/ad/kaniko-build.py b/linux/ecosystem/testrail/6.6.1.1166/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.6.1.1166/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.6.1.1166/ad/requirements.txt b/linux/ecosystem/testrail/6.6.1.1166/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.6.1.1166/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.6.1.1166/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.6.1.1166/ldap/Makefile b/linux/ecosystem/testrail/6.6.1.1166/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.6.1.1166/ldap/Makefile +++ b/linux/ecosystem/testrail/6.6.1.1166/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.6.1.1166/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.6.1.1166/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.6.1.1166/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.6.1.1166/ldap/requirements.txt b/linux/ecosystem/testrail/6.6.1.1166/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.6.1.1166/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.6.1.1166/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.6.1.1166/main/Makefile b/linux/ecosystem/testrail/6.6.1.1166/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.6.1.1166/main/Makefile +++ b/linux/ecosystem/testrail/6.6.1.1166/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.6.1.1166/main/kaniko-build.py b/linux/ecosystem/testrail/6.6.1.1166/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.6.1.1166/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.6.1.1166/main/requirements.txt b/linux/ecosystem/testrail/6.6.1.1166/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.6.1.1166/main/requirements.txt +++ b/linux/ecosystem/testrail/6.6.1.1166/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.7.1.1020/ad/Makefile b/linux/ecosystem/testrail/6.7.1.1020/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.7.1.1020/ad/Makefile +++ b/linux/ecosystem/testrail/6.7.1.1020/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.7.1.1020/ad/kaniko-build.py b/linux/ecosystem/testrail/6.7.1.1020/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.7.1.1020/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.7.1.1020/ad/requirements.txt b/linux/ecosystem/testrail/6.7.1.1020/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.7.1.1020/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.7.1.1020/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.7.1.1020/ldap/Makefile b/linux/ecosystem/testrail/6.7.1.1020/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.7.1.1020/ldap/Makefile +++ b/linux/ecosystem/testrail/6.7.1.1020/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.7.1.1020/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.7.1.1020/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.7.1.1020/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.7.1.1020/ldap/requirements.txt b/linux/ecosystem/testrail/6.7.1.1020/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.7.1.1020/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.7.1.1020/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.7.1.1020/main/Makefile b/linux/ecosystem/testrail/6.7.1.1020/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.7.1.1020/main/Makefile +++ b/linux/ecosystem/testrail/6.7.1.1020/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.7.1.1020/main/kaniko-build.py b/linux/ecosystem/testrail/6.7.1.1020/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.7.1.1020/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.7.1.1020/main/requirements.txt b/linux/ecosystem/testrail/6.7.1.1020/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.7.1.1020/main/requirements.txt +++ b/linux/ecosystem/testrail/6.7.1.1020/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.7.2.1037/ad/Makefile b/linux/ecosystem/testrail/6.7.2.1037/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.7.2.1037/ad/Makefile +++ b/linux/ecosystem/testrail/6.7.2.1037/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.7.2.1037/ad/kaniko-build.py b/linux/ecosystem/testrail/6.7.2.1037/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.7.2.1037/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.7.2.1037/ad/requirements.txt b/linux/ecosystem/testrail/6.7.2.1037/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.7.2.1037/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.7.2.1037/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.7.2.1037/ldap/Makefile b/linux/ecosystem/testrail/6.7.2.1037/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.7.2.1037/ldap/Makefile +++ b/linux/ecosystem/testrail/6.7.2.1037/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.7.2.1037/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.7.2.1037/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.7.2.1037/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.7.2.1037/ldap/requirements.txt b/linux/ecosystem/testrail/6.7.2.1037/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.7.2.1037/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.7.2.1037/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.7.2.1037/main/Makefile b/linux/ecosystem/testrail/6.7.2.1037/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.7.2.1037/main/Makefile +++ b/linux/ecosystem/testrail/6.7.2.1037/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.7.2.1037/main/kaniko-build.py b/linux/ecosystem/testrail/6.7.2.1037/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.7.2.1037/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.7.2.1037/main/requirements.txt b/linux/ecosystem/testrail/6.7.2.1037/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.7.2.1037/main/requirements.txt +++ b/linux/ecosystem/testrail/6.7.2.1037/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.7.2.1043/ad/Makefile b/linux/ecosystem/testrail/6.7.2.1043/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.7.2.1043/ad/Makefile +++ b/linux/ecosystem/testrail/6.7.2.1043/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.7.2.1043/ad/kaniko-build.py b/linux/ecosystem/testrail/6.7.2.1043/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.7.2.1043/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.7.2.1043/ad/requirements.txt b/linux/ecosystem/testrail/6.7.2.1043/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.7.2.1043/ad/requirements.txt +++ b/linux/ecosystem/testrail/6.7.2.1043/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.7.2.1043/ldap/Makefile b/linux/ecosystem/testrail/6.7.2.1043/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.7.2.1043/ldap/Makefile +++ b/linux/ecosystem/testrail/6.7.2.1043/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.7.2.1043/ldap/kaniko-build.py b/linux/ecosystem/testrail/6.7.2.1043/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.7.2.1043/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.7.2.1043/ldap/requirements.txt b/linux/ecosystem/testrail/6.7.2.1043/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.7.2.1043/ldap/requirements.txt +++ b/linux/ecosystem/testrail/6.7.2.1043/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/6.7.2.1043/main/Makefile b/linux/ecosystem/testrail/6.7.2.1043/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/6.7.2.1043/main/Makefile +++ b/linux/ecosystem/testrail/6.7.2.1043/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/6.7.2.1043/main/kaniko-build.py b/linux/ecosystem/testrail/6.7.2.1043/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/6.7.2.1043/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/6.7.2.1043/main/requirements.txt b/linux/ecosystem/testrail/6.7.2.1043/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/6.7.2.1043/main/requirements.txt +++ b/linux/ecosystem/testrail/6.7.2.1043/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.0.1057/ad/Makefile b/linux/ecosystem/testrail/7.0.0.1057/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.0.1057/ad/Makefile +++ b/linux/ecosystem/testrail/7.0.0.1057/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.0.1057/ad/kaniko-build.py b/linux/ecosystem/testrail/7.0.0.1057/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.0.1057/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.0.1057/ad/requirements.txt b/linux/ecosystem/testrail/7.0.0.1057/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.0.1057/ad/requirements.txt +++ b/linux/ecosystem/testrail/7.0.0.1057/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.0.1057/ldap/Makefile b/linux/ecosystem/testrail/7.0.0.1057/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.0.1057/ldap/Makefile +++ b/linux/ecosystem/testrail/7.0.0.1057/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.0.1057/ldap/kaniko-build.py b/linux/ecosystem/testrail/7.0.0.1057/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.0.1057/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.0.1057/ldap/requirements.txt b/linux/ecosystem/testrail/7.0.0.1057/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.0.1057/ldap/requirements.txt +++ b/linux/ecosystem/testrail/7.0.0.1057/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.0.1057/main/Makefile b/linux/ecosystem/testrail/7.0.0.1057/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.0.1057/main/Makefile +++ b/linux/ecosystem/testrail/7.0.0.1057/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.0.1057/main/kaniko-build.py b/linux/ecosystem/testrail/7.0.0.1057/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.0.1057/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.0.1057/main/requirements.txt b/linux/ecosystem/testrail/7.0.0.1057/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.0.1057/main/requirements.txt +++ b/linux/ecosystem/testrail/7.0.0.1057/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.1.1002/ad/Makefile b/linux/ecosystem/testrail/7.0.1.1002/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.1.1002/ad/Makefile +++ b/linux/ecosystem/testrail/7.0.1.1002/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.1.1002/ad/kaniko-build.py b/linux/ecosystem/testrail/7.0.1.1002/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.1.1002/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.1.1002/ad/requirements.txt b/linux/ecosystem/testrail/7.0.1.1002/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.1.1002/ad/requirements.txt +++ b/linux/ecosystem/testrail/7.0.1.1002/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.1.1002/ldap/Makefile b/linux/ecosystem/testrail/7.0.1.1002/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.1.1002/ldap/Makefile +++ b/linux/ecosystem/testrail/7.0.1.1002/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.1.1002/ldap/kaniko-build.py b/linux/ecosystem/testrail/7.0.1.1002/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.1.1002/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.1.1002/ldap/requirements.txt b/linux/ecosystem/testrail/7.0.1.1002/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.1.1002/ldap/requirements.txt +++ b/linux/ecosystem/testrail/7.0.1.1002/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.1.1002/main/Makefile b/linux/ecosystem/testrail/7.0.1.1002/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.1.1002/main/Makefile +++ b/linux/ecosystem/testrail/7.0.1.1002/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.1.1002/main/kaniko-build.py b/linux/ecosystem/testrail/7.0.1.1002/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.1.1002/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.1.1002/main/requirements.txt b/linux/ecosystem/testrail/7.0.1.1002/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.1.1002/main/requirements.txt +++ b/linux/ecosystem/testrail/7.0.1.1002/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.1.1013/ad/Makefile b/linux/ecosystem/testrail/7.0.1.1013/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.1.1013/ad/Makefile +++ b/linux/ecosystem/testrail/7.0.1.1013/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.1.1013/ad/kaniko-build.py b/linux/ecosystem/testrail/7.0.1.1013/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.1.1013/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.1.1013/ad/requirements.txt b/linux/ecosystem/testrail/7.0.1.1013/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.1.1013/ad/requirements.txt +++ b/linux/ecosystem/testrail/7.0.1.1013/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.1.1013/ldap/Makefile b/linux/ecosystem/testrail/7.0.1.1013/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.1.1013/ldap/Makefile +++ b/linux/ecosystem/testrail/7.0.1.1013/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.1.1013/ldap/kaniko-build.py b/linux/ecosystem/testrail/7.0.1.1013/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.1.1013/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.1.1013/ldap/requirements.txt b/linux/ecosystem/testrail/7.0.1.1013/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.1.1013/ldap/requirements.txt +++ b/linux/ecosystem/testrail/7.0.1.1013/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.1.1013/main/Makefile b/linux/ecosystem/testrail/7.0.1.1013/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.1.1013/main/Makefile +++ b/linux/ecosystem/testrail/7.0.1.1013/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.1.1013/main/kaniko-build.py b/linux/ecosystem/testrail/7.0.1.1013/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.1.1013/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.1.1013/main/requirements.txt b/linux/ecosystem/testrail/7.0.1.1013/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.1.1013/main/requirements.txt +++ b/linux/ecosystem/testrail/7.0.1.1013/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.2.1014/ad/Makefile b/linux/ecosystem/testrail/7.0.2.1014/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.2.1014/ad/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1014/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.2.1014/ad/kaniko-build.py b/linux/ecosystem/testrail/7.0.2.1014/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.2.1014/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.2.1014/ad/requirements.txt b/linux/ecosystem/testrail/7.0.2.1014/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.2.1014/ad/requirements.txt +++ b/linux/ecosystem/testrail/7.0.2.1014/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.2.1014/ldap/Makefile b/linux/ecosystem/testrail/7.0.2.1014/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.2.1014/ldap/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1014/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.2.1014/ldap/kaniko-build.py b/linux/ecosystem/testrail/7.0.2.1014/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.2.1014/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.2.1014/ldap/requirements.txt b/linux/ecosystem/testrail/7.0.2.1014/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.2.1014/ldap/requirements.txt +++ b/linux/ecosystem/testrail/7.0.2.1014/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.2.1014/main/Makefile b/linux/ecosystem/testrail/7.0.2.1014/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.2.1014/main/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1014/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.2.1014/main/kaniko-build.py b/linux/ecosystem/testrail/7.0.2.1014/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.2.1014/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.2.1014/main/requirements.txt b/linux/ecosystem/testrail/7.0.2.1014/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.2.1014/main/requirements.txt +++ b/linux/ecosystem/testrail/7.0.2.1014/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.2.1015/ad/Makefile b/linux/ecosystem/testrail/7.0.2.1015/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.2.1015/ad/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1015/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.2.1015/ad/kaniko-build.py b/linux/ecosystem/testrail/7.0.2.1015/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.2.1015/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.2.1015/ad/requirements.txt b/linux/ecosystem/testrail/7.0.2.1015/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.2.1015/ad/requirements.txt +++ b/linux/ecosystem/testrail/7.0.2.1015/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.2.1015/ldap/Makefile b/linux/ecosystem/testrail/7.0.2.1015/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.2.1015/ldap/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1015/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.2.1015/ldap/kaniko-build.py b/linux/ecosystem/testrail/7.0.2.1015/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.2.1015/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.2.1015/ldap/requirements.txt b/linux/ecosystem/testrail/7.0.2.1015/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.2.1015/ldap/requirements.txt +++ b/linux/ecosystem/testrail/7.0.2.1015/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.2.1015/main/Makefile b/linux/ecosystem/testrail/7.0.2.1015/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.2.1015/main/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1015/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.2.1015/main/kaniko-build.py b/linux/ecosystem/testrail/7.0.2.1015/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.2.1015/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.2.1015/main/requirements.txt b/linux/ecosystem/testrail/7.0.2.1015/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.2.1015/main/requirements.txt +++ b/linux/ecosystem/testrail/7.0.2.1015/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.2.1016/ad/Makefile b/linux/ecosystem/testrail/7.0.2.1016/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.2.1016/ad/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1016/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.2.1016/ad/kaniko-build.py b/linux/ecosystem/testrail/7.0.2.1016/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.2.1016/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.2.1016/ad/requirements.txt b/linux/ecosystem/testrail/7.0.2.1016/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.2.1016/ad/requirements.txt +++ b/linux/ecosystem/testrail/7.0.2.1016/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.2.1016/ldap/Makefile b/linux/ecosystem/testrail/7.0.2.1016/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.2.1016/ldap/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1016/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.2.1016/ldap/kaniko-build.py b/linux/ecosystem/testrail/7.0.2.1016/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.2.1016/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.2.1016/ldap/requirements.txt b/linux/ecosystem/testrail/7.0.2.1016/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.2.1016/ldap/requirements.txt +++ b/linux/ecosystem/testrail/7.0.2.1016/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.0.2.1016/main/Makefile b/linux/ecosystem/testrail/7.0.2.1016/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.0.2.1016/main/Makefile +++ b/linux/ecosystem/testrail/7.0.2.1016/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.0.2.1016/main/kaniko-build.py b/linux/ecosystem/testrail/7.0.2.1016/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.0.2.1016/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.0.2.1016/main/requirements.txt b/linux/ecosystem/testrail/7.0.2.1016/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.0.2.1016/main/requirements.txt +++ b/linux/ecosystem/testrail/7.0.2.1016/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.4.1.8079/ad/Makefile b/linux/ecosystem/testrail/7.4.1.8079/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.4.1.8079/ad/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8079/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.4.1.8079/ad/kaniko-build.py b/linux/ecosystem/testrail/7.4.1.8079/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.4.1.8079/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.4.1.8079/ad/requirements.txt b/linux/ecosystem/testrail/7.4.1.8079/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.4.1.8079/ad/requirements.txt +++ b/linux/ecosystem/testrail/7.4.1.8079/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.4.1.8079/ldap/Makefile b/linux/ecosystem/testrail/7.4.1.8079/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.4.1.8079/ldap/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8079/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.4.1.8079/ldap/kaniko-build.py b/linux/ecosystem/testrail/7.4.1.8079/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.4.1.8079/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.4.1.8079/ldap/requirements.txt b/linux/ecosystem/testrail/7.4.1.8079/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.4.1.8079/ldap/requirements.txt +++ b/linux/ecosystem/testrail/7.4.1.8079/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.4.1.8079/main/Makefile b/linux/ecosystem/testrail/7.4.1.8079/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.4.1.8079/main/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8079/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.4.1.8079/main/kaniko-build.py b/linux/ecosystem/testrail/7.4.1.8079/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.4.1.8079/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.4.1.8079/main/requirements.txt b/linux/ecosystem/testrail/7.4.1.8079/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.4.1.8079/main/requirements.txt +++ b/linux/ecosystem/testrail/7.4.1.8079/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.4.1.8091/ad/Makefile b/linux/ecosystem/testrail/7.4.1.8091/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.4.1.8091/ad/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8091/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.4.1.8091/ad/kaniko-build.py b/linux/ecosystem/testrail/7.4.1.8091/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.4.1.8091/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.4.1.8091/ad/requirements.txt b/linux/ecosystem/testrail/7.4.1.8091/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.4.1.8091/ad/requirements.txt +++ b/linux/ecosystem/testrail/7.4.1.8091/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.4.1.8091/ldap/Makefile b/linux/ecosystem/testrail/7.4.1.8091/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.4.1.8091/ldap/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8091/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.4.1.8091/ldap/kaniko-build.py b/linux/ecosystem/testrail/7.4.1.8091/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.4.1.8091/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.4.1.8091/ldap/requirements.txt b/linux/ecosystem/testrail/7.4.1.8091/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.4.1.8091/ldap/requirements.txt +++ b/linux/ecosystem/testrail/7.4.1.8091/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.4.1.8091/main/Makefile b/linux/ecosystem/testrail/7.4.1.8091/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.4.1.8091/main/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8091/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.4.1.8091/main/kaniko-build.py b/linux/ecosystem/testrail/7.4.1.8091/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.4.1.8091/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.4.1.8091/main/requirements.txt b/linux/ecosystem/testrail/7.4.1.8091/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.4.1.8091/main/requirements.txt +++ b/linux/ecosystem/testrail/7.4.1.8091/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.4.1.8092/ad/Makefile b/linux/ecosystem/testrail/7.4.1.8092/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.4.1.8092/ad/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8092/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.4.1.8092/ad/kaniko-build.py b/linux/ecosystem/testrail/7.4.1.8092/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.4.1.8092/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.4.1.8092/ad/requirements.txt b/linux/ecosystem/testrail/7.4.1.8092/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.4.1.8092/ad/requirements.txt +++ b/linux/ecosystem/testrail/7.4.1.8092/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.4.1.8092/ldap/Makefile b/linux/ecosystem/testrail/7.4.1.8092/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.4.1.8092/ldap/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8092/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.4.1.8092/ldap/kaniko-build.py b/linux/ecosystem/testrail/7.4.1.8092/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.4.1.8092/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.4.1.8092/ldap/requirements.txt b/linux/ecosystem/testrail/7.4.1.8092/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.4.1.8092/ldap/requirements.txt +++ b/linux/ecosystem/testrail/7.4.1.8092/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.4.1.8092/main/Makefile b/linux/ecosystem/testrail/7.4.1.8092/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.4.1.8092/main/Makefile +++ b/linux/ecosystem/testrail/7.4.1.8092/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.4.1.8092/main/kaniko-build.py b/linux/ecosystem/testrail/7.4.1.8092/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.4.1.8092/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.4.1.8092/main/requirements.txt b/linux/ecosystem/testrail/7.4.1.8092/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.4.1.8092/main/requirements.txt +++ b/linux/ecosystem/testrail/7.4.1.8092/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.5.1.7010/ad/Makefile b/linux/ecosystem/testrail/7.5.1.7010/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.5.1.7010/ad/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7010/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.5.1.7010/ad/kaniko-build.py b/linux/ecosystem/testrail/7.5.1.7010/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.5.1.7010/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.5.1.7010/ad/requirements.txt b/linux/ecosystem/testrail/7.5.1.7010/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.5.1.7010/ad/requirements.txt +++ b/linux/ecosystem/testrail/7.5.1.7010/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.5.1.7010/ldap/Makefile b/linux/ecosystem/testrail/7.5.1.7010/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.5.1.7010/ldap/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7010/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.5.1.7010/ldap/kaniko-build.py b/linux/ecosystem/testrail/7.5.1.7010/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.5.1.7010/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.5.1.7010/ldap/requirements.txt b/linux/ecosystem/testrail/7.5.1.7010/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.5.1.7010/ldap/requirements.txt +++ b/linux/ecosystem/testrail/7.5.1.7010/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.5.1.7010/main/Makefile b/linux/ecosystem/testrail/7.5.1.7010/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.5.1.7010/main/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7010/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.5.1.7010/main/kaniko-build.py b/linux/ecosystem/testrail/7.5.1.7010/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.5.1.7010/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.5.1.7010/main/requirements.txt b/linux/ecosystem/testrail/7.5.1.7010/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.5.1.7010/main/requirements.txt +++ b/linux/ecosystem/testrail/7.5.1.7010/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.5.1.7012/ad/Makefile b/linux/ecosystem/testrail/7.5.1.7012/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.5.1.7012/ad/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7012/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.5.1.7012/ad/kaniko-build.py b/linux/ecosystem/testrail/7.5.1.7012/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.5.1.7012/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.5.1.7012/ad/requirements.txt b/linux/ecosystem/testrail/7.5.1.7012/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.5.1.7012/ad/requirements.txt +++ b/linux/ecosystem/testrail/7.5.1.7012/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.5.1.7012/ldap/Makefile b/linux/ecosystem/testrail/7.5.1.7012/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.5.1.7012/ldap/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7012/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.5.1.7012/ldap/kaniko-build.py b/linux/ecosystem/testrail/7.5.1.7012/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.5.1.7012/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.5.1.7012/ldap/requirements.txt b/linux/ecosystem/testrail/7.5.1.7012/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.5.1.7012/ldap/requirements.txt +++ b/linux/ecosystem/testrail/7.5.1.7012/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.5.1.7012/main/Makefile b/linux/ecosystem/testrail/7.5.1.7012/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.5.1.7012/main/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7012/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.5.1.7012/main/kaniko-build.py b/linux/ecosystem/testrail/7.5.1.7012/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.5.1.7012/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.5.1.7012/main/requirements.txt b/linux/ecosystem/testrail/7.5.1.7012/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.5.1.7012/main/requirements.txt +++ b/linux/ecosystem/testrail/7.5.1.7012/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.5.1.7013/ad/Makefile b/linux/ecosystem/testrail/7.5.1.7013/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.5.1.7013/ad/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7013/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.5.1.7013/ad/kaniko-build.py b/linux/ecosystem/testrail/7.5.1.7013/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.5.1.7013/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.5.1.7013/ad/requirements.txt b/linux/ecosystem/testrail/7.5.1.7013/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.5.1.7013/ad/requirements.txt +++ b/linux/ecosystem/testrail/7.5.1.7013/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.5.1.7013/ldap/Makefile b/linux/ecosystem/testrail/7.5.1.7013/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.5.1.7013/ldap/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7013/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.5.1.7013/ldap/kaniko-build.py b/linux/ecosystem/testrail/7.5.1.7013/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.5.1.7013/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.5.1.7013/ldap/requirements.txt b/linux/ecosystem/testrail/7.5.1.7013/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.5.1.7013/ldap/requirements.txt +++ b/linux/ecosystem/testrail/7.5.1.7013/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.5.1.7013/main/Makefile b/linux/ecosystem/testrail/7.5.1.7013/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.5.1.7013/main/Makefile +++ b/linux/ecosystem/testrail/7.5.1.7013/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.5.1.7013/main/kaniko-build.py b/linux/ecosystem/testrail/7.5.1.7013/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.5.1.7013/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.5.1.7013/main/requirements.txt b/linux/ecosystem/testrail/7.5.1.7013/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.5.1.7013/main/requirements.txt +++ b/linux/ecosystem/testrail/7.5.1.7013/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.5.2.1002/ad/Makefile b/linux/ecosystem/testrail/7.5.2.1002/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.5.2.1002/ad/Makefile +++ b/linux/ecosystem/testrail/7.5.2.1002/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.5.2.1002/ad/kaniko-build.py b/linux/ecosystem/testrail/7.5.2.1002/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.5.2.1002/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.5.2.1002/ad/requirements.txt b/linux/ecosystem/testrail/7.5.2.1002/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.5.2.1002/ad/requirements.txt +++ b/linux/ecosystem/testrail/7.5.2.1002/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.5.2.1002/ldap/Makefile b/linux/ecosystem/testrail/7.5.2.1002/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.5.2.1002/ldap/Makefile +++ b/linux/ecosystem/testrail/7.5.2.1002/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.5.2.1002/ldap/kaniko-build.py b/linux/ecosystem/testrail/7.5.2.1002/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.5.2.1002/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.5.2.1002/ldap/requirements.txt b/linux/ecosystem/testrail/7.5.2.1002/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.5.2.1002/ldap/requirements.txt +++ b/linux/ecosystem/testrail/7.5.2.1002/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.5.2.1002/main/Makefile b/linux/ecosystem/testrail/7.5.2.1002/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.5.2.1002/main/Makefile +++ b/linux/ecosystem/testrail/7.5.2.1002/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.5.2.1002/main/kaniko-build.py b/linux/ecosystem/testrail/7.5.2.1002/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.5.2.1002/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.5.2.1002/main/requirements.txt b/linux/ecosystem/testrail/7.5.2.1002/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.5.2.1002/main/requirements.txt +++ b/linux/ecosystem/testrail/7.5.2.1002/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.5.3.1000/ad/Makefile b/linux/ecosystem/testrail/7.5.3.1000/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.5.3.1000/ad/Makefile +++ b/linux/ecosystem/testrail/7.5.3.1000/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.5.3.1000/ad/kaniko-build.py b/linux/ecosystem/testrail/7.5.3.1000/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.5.3.1000/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.5.3.1000/ad/requirements.txt b/linux/ecosystem/testrail/7.5.3.1000/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.5.3.1000/ad/requirements.txt +++ b/linux/ecosystem/testrail/7.5.3.1000/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.5.3.1000/ldap/Makefile b/linux/ecosystem/testrail/7.5.3.1000/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.5.3.1000/ldap/Makefile +++ b/linux/ecosystem/testrail/7.5.3.1000/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.5.3.1000/ldap/kaniko-build.py b/linux/ecosystem/testrail/7.5.3.1000/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.5.3.1000/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.5.3.1000/ldap/requirements.txt b/linux/ecosystem/testrail/7.5.3.1000/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.5.3.1000/ldap/requirements.txt +++ b/linux/ecosystem/testrail/7.5.3.1000/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/7.5.3.1000/main/Makefile b/linux/ecosystem/testrail/7.5.3.1000/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/7.5.3.1000/main/Makefile +++ b/linux/ecosystem/testrail/7.5.3.1000/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/7.5.3.1000/main/kaniko-build.py b/linux/ecosystem/testrail/7.5.3.1000/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/7.5.3.1000/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/7.5.3.1000/main/requirements.txt b/linux/ecosystem/testrail/7.5.3.1000/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/7.5.3.1000/main/requirements.txt +++ b/linux/ecosystem/testrail/7.5.3.1000/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/8.0.0.1089/ad/Makefile b/linux/ecosystem/testrail/8.0.0.1089/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/8.0.0.1089/ad/Makefile +++ b/linux/ecosystem/testrail/8.0.0.1089/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/8.0.0.1089/ad/kaniko-build.py b/linux/ecosystem/testrail/8.0.0.1089/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/8.0.0.1089/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/8.0.0.1089/ad/requirements.txt b/linux/ecosystem/testrail/8.0.0.1089/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/8.0.0.1089/ad/requirements.txt +++ b/linux/ecosystem/testrail/8.0.0.1089/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/8.0.0.1089/ldap/Makefile b/linux/ecosystem/testrail/8.0.0.1089/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/8.0.0.1089/ldap/Makefile +++ b/linux/ecosystem/testrail/8.0.0.1089/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/8.0.0.1089/ldap/kaniko-build.py b/linux/ecosystem/testrail/8.0.0.1089/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/8.0.0.1089/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/8.0.0.1089/ldap/requirements.txt b/linux/ecosystem/testrail/8.0.0.1089/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/8.0.0.1089/ldap/requirements.txt +++ b/linux/ecosystem/testrail/8.0.0.1089/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/8.0.0.1089/main/Makefile b/linux/ecosystem/testrail/8.0.0.1089/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/8.0.0.1089/main/Makefile +++ b/linux/ecosystem/testrail/8.0.0.1089/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/8.0.0.1089/main/kaniko-build.py b/linux/ecosystem/testrail/8.0.0.1089/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/8.0.0.1089/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/8.0.0.1089/main/requirements.txt b/linux/ecosystem/testrail/8.0.0.1089/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/8.0.0.1089/main/requirements.txt +++ b/linux/ecosystem/testrail/8.0.0.1089/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/8.0.1.1029/ad/Makefile b/linux/ecosystem/testrail/8.0.1.1029/ad/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/8.0.1.1029/ad/Makefile +++ b/linux/ecosystem/testrail/8.0.1.1029/ad/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/8.0.1.1029/ad/kaniko-build.py b/linux/ecosystem/testrail/8.0.1.1029/ad/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/8.0.1.1029/ad/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/8.0.1.1029/ad/requirements.txt b/linux/ecosystem/testrail/8.0.1.1029/ad/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/8.0.1.1029/ad/requirements.txt +++ b/linux/ecosystem/testrail/8.0.1.1029/ad/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/8.0.1.1029/ldap/Makefile b/linux/ecosystem/testrail/8.0.1.1029/ldap/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/8.0.1.1029/ldap/Makefile +++ b/linux/ecosystem/testrail/8.0.1.1029/ldap/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/8.0.1.1029/ldap/kaniko-build.py b/linux/ecosystem/testrail/8.0.1.1029/ldap/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/8.0.1.1029/ldap/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/8.0.1.1029/ldap/requirements.txt b/linux/ecosystem/testrail/8.0.1.1029/ldap/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/8.0.1.1029/ldap/requirements.txt +++ b/linux/ecosystem/testrail/8.0.1.1029/ldap/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/testrail/8.0.1.1029/main/Makefile b/linux/ecosystem/testrail/8.0.1.1029/main/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/testrail/8.0.1.1029/main/Makefile +++ b/linux/ecosystem/testrail/8.0.1.1029/main/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/testrail/8.0.1.1029/main/kaniko-build.py b/linux/ecosystem/testrail/8.0.1.1029/main/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/testrail/8.0.1.1029/main/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/testrail/8.0.1.1029/main/requirements.txt b/linux/ecosystem/testrail/8.0.1.1029/main/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/testrail/8.0.1.1029/main/requirements.txt +++ b/linux/ecosystem/testrail/8.0.1.1029/main/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/torrserver/Makefile b/linux/ecosystem/torrserver/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/torrserver/Makefile +++ b/linux/ecosystem/torrserver/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/torrserver/kaniko-build.py b/linux/ecosystem/torrserver/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/torrserver/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/torrserver/requirements.txt b/linux/ecosystem/torrserver/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/torrserver/requirements.txt +++ b/linux/ecosystem/torrserver/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/torrust-index/Makefile b/linux/ecosystem/torrust-index/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/torrust-index/Makefile +++ b/linux/ecosystem/torrust-index/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/torrust-index/kaniko-build.py b/linux/ecosystem/torrust-index/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/torrust-index/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/torrust-index/requirements.txt b/linux/ecosystem/torrust-index/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/torrust-index/requirements.txt +++ b/linux/ecosystem/torrust-index/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/torrust-tracker/Makefile b/linux/ecosystem/torrust-tracker/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/torrust-tracker/Makefile +++ b/linux/ecosystem/torrust-tracker/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/torrust-tracker/kaniko-build.py b/linux/ecosystem/torrust-tracker/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/torrust-tracker/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/torrust-tracker/requirements.txt b/linux/ecosystem/torrust-tracker/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/torrust-tracker/requirements.txt +++ b/linux/ecosystem/torrust-tracker/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper diff --git a/linux/ecosystem/vk2discord/Makefile b/linux/ecosystem/vk2discord/Makefile index 3383c9699..5e0d54db0 100644 --- a/linux/ecosystem/vk2discord/Makefile +++ b/linux/ecosystem/vk2discord/Makefile @@ -9,7 +9,7 @@ app: build: make pip - python3 kaniko-build.py --version + kaniko-wrapper --version dry: make dry-run @@ -18,7 +18,7 @@ test: make dry-run dry-run: - python3 kaniko-build.py --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run + kaniko-wrapper --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug --dry-run pip: rm -rf /usr/lib/python3.6/EXTERNALLY-MANAGED @@ -37,7 +37,7 @@ build-compose: deploy: make pip - python3 kaniko-build.py --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug + kaniko-wrapper --deploy --kaniko-image gcr.io/kaniko-project/executor:v1.23.2-debug deploy-compose: docker-compose push diff --git a/linux/ecosystem/vk2discord/kaniko-build.py b/linux/ecosystem/vk2discord/kaniko-build.py deleted file mode 100644 index e693b5c17..000000000 --- a/linux/ecosystem/vk2discord/kaniko-build.py +++ /dev/null @@ -1,196 +0,0 @@ -import os -import shutil -import argparse -import yaml -import subprocess -from collections import defaultdict -from concurrent.futures import ThreadPoolExecutor, as_completed -from dotenv import load_dotenv -import logging -import sys - -# Script version -SCRIPT_VERSION = "1.0.1.0" - -# ASCII art for EpicMorg -ASCII_ART = r""" -+=================================================+ -| ____| _) \ | | -| __| __ \ | __| |\/ | _ \ __| _` | | -| | | | | ( | | ( | | ( | | -|_____| .__/ _| \___| _| _| \___/ _| \__, | | -| | / _| _) | |___/ | -| ' / _` | __ \ | | / _ \ | -| . \ ( | | | | < ( | | -|_|\_\ \__,_| _| _| _| _|\_\ \___/ | -|\ \ / | -| \ \ \ / __| _` | __ \ __ \ _ \ __|| -| \ \ \ / | ( | | | | | __/ | | -| \_/\_/ _| \__,_| .__/ .__/ \___| _| | -| _| _| | -+=================================================+ -""" - -# Load environment variables from .env file -load_dotenv() - -def setup_logging(): - logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - -def parse_args(): - parser = argparse.ArgumentParser(description="EpicMorg: Kaniko-Compose Wrapper", add_help=False) - parser.add_argument('--compose-file', default=os.getenv('COMPOSE_FILE', 'docker-compose.yml'), help='Path to docker-compose.yml file') - parser.add_argument('--kaniko-image', default=os.getenv('KANIKO_IMAGE', 'gcr.io/kaniko-project/executor:latest'), help='Kaniko executor image') - parser.add_argument('--push', '--deploy', '-d', '-p', action='store_true', help='Deploy the built images to the registry') - parser.add_argument('--dry-run', '--dry', action='store_true', help='Dry run: build images without pushing and with cleanup') - parser.add_argument('--version', '-v', action='store_true', help='Show script version') - parser.add_argument('--help', '-h', action='store_true', help='Show this help message and exit') - return parser.parse_args() - -def load_compose_file(file_path): - with open(file_path, 'r') as file: - return yaml.safe_load(file) - -def build_with_kaniko(service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry): - kaniko_command = [ - 'docker', 'run', - '--rm', - '-t', - '-v', f'{os.path.abspath(build_context)}:/workspace', - ] - - # Add Docker config mounts for both read-only access - kaniko_command.extend([ - '-v', '/var/run/docker.sock:/var/run/docker.sock:ro', # Access to Docker daemon - '-v', f'{os.path.expanduser("~")}/.docker:/kaniko/.docker:ro', # Use existing Docker credentials in read-only mode - ]) - - kaniko_command.extend([ - kaniko_image, - '--context', '/workspace', - '--dockerfile', f'/workspace/{dockerfile}', - '--compressed-caching', - '--single-snapshot', - '--cleanup' - ]) - - if deploy: - kaniko_command.extend([ - '--destination', image_name - ]) - elif dry: - kaniko_command.extend([ - '--no-push' - ]) - else: - kaniko_command.extend([ - '--no-push' - ]) - - # Add build arguments if they exist - for arg_name, arg_value in build_args.items(): - kaniko_command.extend(['--build-arg', f'{arg_name}={arg_value}']) - - logging.info(f"Building {service_name} with Kaniko: {' '.join(kaniko_command)}") - - process = subprocess.Popen(kaniko_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - - # Stream output in real-time - for line in process.stdout: - logging.info(line.strip()) - - process.wait() - - if process.returncode == 0: - logging.info(f"Successfully built {service_name}") - else: - for line in process.stderr: - logging.error(line.strip()) - logging.error(f"Error building {service_name}") - raise Exception(f"Failed to build {service_name}") - -def show_help(): - print(ASCII_ART) - print("EpicMorg: Kaniko-Compose Wrapper\n") - print("Arguments:") - print("--compose-file Path to docker-compose.yml file") - print("--kaniko-image Kaniko executor image") - print("--push, --deploy, -d, -p Deploy the built images to the registry") - print("--dry-run, --dry Dry run: build images without pushing and with cleanup") - print("--version, -v Show script version") - print("--help, -h Show this help message and exit") - -def show_version(): - print(ASCII_ART) - print(f"EpicMorg: Kaniko-Compose Wrapper {SCRIPT_VERSION}, Python: {sys.version}") - -def main(): - setup_logging() - - args = parse_args() - - # Show help and exit if --help is provided - if args.help: - show_help() - return - - # Show version and exit if --version or no relevant arguments are provided - if args.version or not (args.push or args.dry_run or args.compose_file != 'docker-compose.yml' or args.kaniko_image != 'gcr.io/kaniko-project/executor:latest'): - show_version() - return - - compose_file = args.compose_file - kaniko_image = args.kaniko_image - deploy = args.push - dry = args.dry_run - - if not os.path.exists(compose_file): - logging.error(f"{compose_file} not found") - return - - compose_data = load_compose_file(compose_file) - - services = compose_data.get('services', {}) - image_names = defaultdict(int) - - for service_name, service_data in services.items(): - image_name = service_data.get('image') - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - image_names[image_name] += 1 - - for image_name, count in image_names.items(): - if count > 1: - logging.error(f"Error: Image name {image_name} is used {count} times.") - return - - try: - with ThreadPoolExecutor() as executor: - futures = [] - for service_name, service_data in services.items(): - build_data = service_data.get('build', {}) - build_context = build_data.get('context', '.') - dockerfile = build_data.get('dockerfile', 'Dockerfile') - image_name = service_data.get('image') - build_args = build_data.get('args', {}) - - # Substitute environment variables with their values if they exist - build_args = {key: os.getenv(key, value) for key, value in build_args.items()} - - if not image_name: - logging.warning(f"No image specified for service {service_name}") - continue - - futures.append(executor.submit(build_with_kaniko, service_name, build_context, dockerfile, image_name, build_args, kaniko_image, deploy, dry)) - - for future in as_completed(futures): - future.result() - except Exception as exc: - logging.error(f"Build failed: {exc}") - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/linux/ecosystem/vk2discord/requirements.txt b/linux/ecosystem/vk2discord/requirements.txt index 9ed771861..568608d59 100644 --- a/linux/ecosystem/vk2discord/requirements.txt +++ b/linux/ecosystem/vk2discord/requirements.txt @@ -1,2 +1,3 @@ PyYAML python-dotenv +kaniko-wrapper